From 6b01a4f0185930cff578a3a0b68354c5a1cb50cd Mon Sep 17 00:00:00 2001 From: Vandana Kannan Date: Wed, 15 Aug 2018 13:23:42 -0700 Subject: [PATCH] [MXNET-696] Fix undefined name errors (#12137) * Fix undefined name error in neural style example * Fix import exception error * Fix undefined name in AUCMetric * Fix undefined name in a3c example --- example/deep-embedded-clustering/model.py | 4 ++-- example/neural-style/end_to_end/model_vgg19.py | 1 + example/reinforcement-learning/a3c/a3c.py | 2 +- example/sparse/factorization_machine/metric.py | 4 +++- 4 files changed, 7 insertions(+), 4 deletions(-) diff --git a/example/deep-embedded-clustering/model.py b/example/deep-embedded-clustering/model.py index 777634e3cf88..9b6185c9fd18 100644 --- a/example/deep-embedded-clustering/model.py +++ b/example/deep-embedded-clustering/model.py @@ -22,7 +22,7 @@ import numpy as np try: import cPickle as pickle -except ModuleNotFoundError: +except ImportError: import pickle @@ -75,4 +75,4 @@ def load(self, fname): self.args[key][:] = v def setup(self, *args, **kwargs): - raise NotImplementedError("must override this") \ No newline at end of file + raise NotImplementedError("must override this") diff --git a/example/neural-style/end_to_end/model_vgg19.py b/example/neural-style/end_to_end/model_vgg19.py index 0d369ae08f58..1bc38766beb4 100644 --- a/example/neural-style/end_to_end/model_vgg19.py +++ b/example/neural-style/end_to_end/model_vgg19.py @@ -90,6 +90,7 @@ def get_executor_with_style(style, content, input_size, ctx): arg_dict=arg_dict) def get_executor_content(content, input_size, ctx): + out = mx.sym.Group([content]) arg_shapes, output_shapes, aux_shapes = content.infer_shape(data=(1, 3, input_size[0], input_size[1])) arg_names = out.list_arguments() arg_dict = dict(zip(arg_names, [mx.nd.zeros(shape, ctx=ctx) for shape in arg_shapes])) diff --git a/example/reinforcement-learning/a3c/a3c.py b/example/reinforcement-learning/a3c/a3c.py index f74ce77b652d..c100f61304d7 100644 --- a/example/reinforcement-learning/a3c/a3c.py +++ b/example/reinforcement-learning/a3c/a3c.py @@ -203,7 +203,7 @@ def test(): mx.gpu(int(i)) for i in args.gpus.split(',')] # module - dataiter = robo_data.RobosimsDataIter('scenes', args.batch_size, args.input_length, web_viz=True) + dataiter = rl_data.GymDataIter('scenes', args.batch_size, args.input_length, web_viz=True) print(dataiter.provide_data) net = sym.get_symbol_thor(dataiter.act_dim) module = mx.mod.Module(net, data_names=[d[0] for d in dataiter.provide_data], label_names=('policy_label', 'value_label'), context=devs) diff --git a/example/sparse/factorization_machine/metric.py b/example/sparse/factorization_machine/metric.py index 05ef04a0c48e..a8c52c781c0f 100644 --- a/example/sparse/factorization_machine/metric.py +++ b/example/sparse/factorization_machine/metric.py @@ -107,7 +107,9 @@ def update(self, labels, preds): label_sum = label_weight.sum() if label_sum == 0 or label_sum == label_weight.size: raise Exception("AUC with one class is undefined") - + + label_one_num = np.count_nonzero(label_weight) + label_zero_num = len(label_weight) - label_one_num total_area = label_zero_num * label_one_num height = 0 width = 0