Skip to content
This repository has been archived by the owner on Nov 17, 2023. It is now read-only.

[MXNET-696] Fix undefined name errors #12137

Merged
merged 4 commits into from
Aug 15, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions example/deep-embedded-clustering/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import numpy as np
try:
import cPickle as pickle
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why use cPickle? why not just pickle. In fact cPickle is not used in python3. most functions of cPickle is there in pickle

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is correct usage... We first try to use cPickle which is compiled C code in Python 2 and is nice and fast but if we fail to import that (because it is not pip installed on Python 2 or because we are running on Python 3) then we use the normal standard library pickle.

except ModuleNotFoundError:
except ImportError:
import pickle


Expand Down Expand Up @@ -75,4 +75,4 @@ def load(self, fname):
self.args[key][:] = v

def setup(self, *args, **kwargs):
raise NotImplementedError("must override this")
raise NotImplementedError("must override this")
1 change: 1 addition & 0 deletions example/neural-style/end_to_end/model_vgg19.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]))
Expand Down
2 changes: 1 addition & 1 deletion example/reinforcement-learning/a3c/a3c.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 3 additions & 1 deletion example/sparse/factorization_machine/metric.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down