summaryrefslogtreecommitdiff
path: root/python
diff options
context:
space:
mode:
authorphilkr <philkr@users.noreply.github.com>2015-07-07 16:32:46 -0700
committerphilkr <philkr@users.noreply.github.com>2015-07-08 15:17:05 -0700
commit7093b0b6c9216e116046ab1d4d2b9bf2e487a641 (patch)
tree2e24c790e9afe73e9729782cc7ce5d1227afdba7 /python
parent77d66dfc907dd875d69bb9fc12dd950b531e464f (diff)
downloadcaffeonacl-7093b0b6c9216e116046ab1d4d2b9bf2e487a641.tar.gz
caffeonacl-7093b0b6c9216e116046ab1d4d2b9bf2e487a641.tar.bz2
caffeonacl-7093b0b6c9216e116046ab1d4d2b9bf2e487a641.zip
Making the net_spec python3 compatible
Diffstat (limited to 'python')
-rw-r--r--python/caffe/net_spec.py11
-rw-r--r--python/requirements.txt1
2 files changed, 7 insertions, 5 deletions
diff --git a/python/caffe/net_spec.py b/python/caffe/net_spec.py
index f54328d5..1b4814a4 100644
--- a/python/caffe/net_spec.py
+++ b/python/caffe/net_spec.py
@@ -22,6 +22,7 @@ from collections import OrderedDict
from .proto import caffe_pb2
from google import protobuf
+import six
def param_name_dict():
@@ -63,12 +64,12 @@ def assign_proto(proto, name, val):
if isinstance(val[0], dict):
for item in val:
proto_item = getattr(proto, name).add()
- for k, v in item.iteritems():
+ for k, v in six.iteritems(item):
assign_proto(proto_item, k, v)
else:
getattr(proto, name).extend(val)
elif isinstance(val, dict):
- for k, v in val.iteritems():
+ for k, v in six.iteritems(val):
assign_proto(getattr(proto, name), k, v)
else:
setattr(proto, name, val)
@@ -131,7 +132,7 @@ class Function(object):
layer.top.append(self._get_name(top, names, autonames))
layer.name = self._get_name(self.tops[0], names, autonames)
- for k, v in self.params.iteritems():
+ for k, v in six.iteritems(self.params):
# special case to handle generic *params
if k.endswith('param'):
assign_proto(layer, k, v)
@@ -161,10 +162,10 @@ class NetSpec(object):
return self.tops[name]
def to_proto(self):
- names = {v: k for k, v in self.tops.iteritems()}
+ names = {v: k for k, v in six.iteritems(self.tops)}
autonames = {}
layers = OrderedDict()
- for name, top in self.tops.iteritems():
+ for name, top in six.iteritems(self.tops):
top.fn._to_proto(layers, names, autonames)
net = caffe_pb2.NetParameter()
net.layer.extend(layers.values())
diff --git a/python/requirements.txt b/python/requirements.txt
index e0c86c7e..e7d89e67 100644
--- a/python/requirements.txt
+++ b/python/requirements.txt
@@ -14,3 +14,4 @@ protobuf>=2.5.0
python-gflags>=2.0
pyyaml>=3.10
Pillow>=2.3.0
+six>=1.1.0 \ No newline at end of file