Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix load weights #686

Merged
merged 2 commits into from
Jun 25, 2019
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
9 changes: 6 additions & 3 deletions mmdnn/conversion/caffe/caffe_emitter.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@ def load_weights(weight_file):
return

try:
weights_dict = np.load(weight_file).item()
weights_dict = np.load(weight_file, allow_pickle=True).item()
except:
weights_dict = np.load(weight_file, encoding='bytes').item()
weights_dict = np.load(weight_file, allow_pickle=True, encoding='bytes').item()

return weights_dict

Expand Down Expand Up @@ -654,4 +654,7 @@ def emit_Elu(self, IR_node):
self.add_body(1, "n.{:<15} = L.ELU(n.{}, in_place={}, ntop=1)".format(
IR_node.variable_name,
self.parent_variable_name(IR_node),
in_place))
in_place))

def emit_SpaceToDepth(self, IR_node):
self.add_body(1, "")
4 changes: 2 additions & 2 deletions mmdnn/conversion/cntk/cntk_emitter.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,9 @@ def load_weights(weight_file):
return

try:
weights_dict = np.load(weight_file).item()
weights_dict = np.load(weight_file, allow_pickle=True).item()
except:
weights_dict = np.load(weight_file, encoding='bytes').item()
weights_dict = np.load(weight_file, allow_pickle=True, encoding='bytes').item()

return weights_dict

Expand Down
4 changes: 2 additions & 2 deletions mmdnn/conversion/keras/keras2_emitter.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,9 @@ def header_code(self):
weights_dict = dict()
def load_weights_from_file(weight_file):
try:
weights_dict = np.load(weight_file).item()
weights_dict = np.load(weight_file, allow_pickle=True).item()
except:
weights_dict = np.load(weight_file, encoding='bytes').item()
weights_dict = np.load(weight_file, allow_pickle=True, encoding='bytes').item()

return weights_dict

Expand Down
4 changes: 2 additions & 2 deletions mmdnn/conversion/mxnet/mxnet_emitter.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,9 +231,9 @@ def gen_weight_code(self, shape, phase):
return

try:
weights_dict = np.load(weight_file).item()
weights_dict = np.load(weight_file, allow_pickle=True).item()
except:
weights_dict = np.load(weight_file, encoding='bytes').item()
weights_dict = np.load(weight_file, allow_pickle=True, encoding='bytes').item()

arg_params = dict()
aux_params = dict()
Expand Down
4 changes: 2 additions & 2 deletions mmdnn/conversion/onnx/onnx_emitter.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ def load_weights(weight_file):
return

try:
weights_dict = np.load(weight_file).item()
weights_dict = np.load(weight_file, allow_pickle=True).item()
except:
weights_dict = np.load(weight_file, encoding='bytes').item()
weights_dict = np.load(weight_file, allow_pickle=True, encoding='bytes').item()

return weights_dict

Expand Down
4 changes: 2 additions & 2 deletions mmdnn/conversion/pytorch/pytorch_emitter.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,9 @@ def load_weights(weight_file):
return

try:
weights_dict = np.load(weight_file).item()
weights_dict = np.load(weight_file, allow_pickle=True).item()
except:
weights_dict = np.load(weight_file, encoding='bytes').item()
weights_dict = np.load(weight_file, allow_pickle=True, encoding='bytes').item()

return weights_dict

Expand Down
4 changes: 2 additions & 2 deletions mmdnn/conversion/tensorflow/tensorflow_emitter.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ def load_weights(weight_file):
return

try:
weights_dict = np.load(weight_file).item()
weights_dict = np.load(weight_file, allow_pickle=True).item()
except:
weights_dict = np.load(weight_file, encoding='bytes').item()
weights_dict = np.load(weight_file, allow_pickle=True, encoding='bytes').item()

return weights_dict

Expand Down