raghakot / keras-resnet

Residual networks implementation using Keras-1.0 functional API
Other
1.39k stars 616 forks source link

Error with building resnet #8

Closed vrodionovpro closed 7 years ago

vrodionovpro commented 8 years ago

On keras 1.0.5 on my notebook (mac) all fine. But on my Linux today I download keras 1.0.6 and see error ... Average pooling, from (3,3) to (1,1) Traceback (most recent call last): File "/usr/local/lib/python3.5/dist-packages/numpy/core/fromnumeric.py", line 2489, in prod prod = a.prod AttributeError: 'list' object has no attribute 'prod'

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "example.py", line 167, in model = get_residual_model(is_mnist=is_mnist, img_channels=img_channels, img_rows=img_rows, img_cols=img_cols) File "example.py", line 132, in get_residual_model model.add(Flatten()) File "/usr/local/lib/python3.5/dist-packages/Keras-1.0.6-py3.5.egg/keras/models.py", line 146, in add output_tensor = layer(self.outputs[0]) File "/usr/local/lib/python3.5/dist-packages/Keras-1.0.6-py3.5.egg/keras/engine/topology.py", line 485, in call self.add_inbound_node(inbound_layers, node_indices, tensor_indices) File "/usr/local/lib/python3.5/dist-packages/Keras-1.0.6-py3.5.egg/keras/engine/topology.py", line 543, in add_inbound_node Node.create_node(self, inbound_layers, node_indices, tensor_indices) File "/usr/local/lib/python3.5/dist-packages/Keras-1.0.6-py3.5.egg/keras/engine/topology.py", line 148, in create_node output_tensors = to_list(outbound_layer.call(input_tensors[0], mask=input_masks[0])) File "/usr/local/lib/python3.5/dist-packages/Keras-1.0.6-py3.5.egg/keras/layers/core.py", line 311, in call return K.batch_flatten(x) File "/usr/local/lib/python3.5/dist-packages/Keras-1.0.6-py3.5.egg/keras/backend/tensorflow_backend.py", line 646, in batch_flatten x = tf.reshape(x, [-1, np.prod(x.get_shape()[1:].as_list())]) File "/usr/local/lib/python3.5/dist-packages/numpy/core/fromnumeric.py", line 2492, in prod out=out, keepdims=keepdims) File "/usr/local/lib/python3.5/dist-packages/numpy/core/_methods.py", line 35, in _prod return umr_prod(a, axis, dtype, out, keepdims) TypeError: unsupported operand type(s) for *: 'int' and 'NoneType'

Later I found that keras was updated several minutes ago, update all and get other error:

File "example.py", line 167, in model = get_residual_model(is_mnist=is_mnist, img_channels=img_channels, img_rows=img_rows, img_cols=img_cols) File "example.py", line 123, in get_residual_model model.add(Convolution2D(first_layer_channel, 3, 3, border_mode='same', input_shape=(img_channels, img_rows, img_cols))) File "/usr/local/lib/python3.5/dist-packages/Keras-1.0.6-py3.5.egg/keras/models.py", line 114, in add layer.create_input_layer(batch_input_shape, input_dtype) File "/usr/local/lib/python3.5/dist-packages/Keras-1.0.6-py3.5.egg/keras/engine/topology.py", line 341, in create_input_layer self(x) File "/usr/local/lib/python3.5/dist-packages/Keras-1.0.6-py3.5.egg/keras/engine/topology.py", line 458, in call self.build(input_shapes[0]) File "/usr/local/lib/python3.5/dist-packages/Keras-1.0.6-py3.5.egg/keras/layers/convolutional.py", line 296, in build self.W = self.init(self.W_shape, name='{}_W'.format(self.name)) File "/usr/local/lib/python3.5/dist-packages/Keras-1.0.6-py3.5.egg/keras/initializations.py", line 59, in glorot_uniform return uniform(shape, s, name=name) File "/usr/local/lib/python3.5/dist-packages/Keras-1.0.6-py3.5.egg/keras/initializations.py", line 32, in uniform return K.random_uniform_variable(shape, -scale, scale, name=name) File "/usr/local/lib/python3.5/dist-packages/Keras-1.0.6-py3.5.egg/keras/backend/tensorflow_backend.py", line 240, in random_uniform_variable value = tf.random_uniform_initializer(low, high, dtype=tf_dtype)(shape) File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/ops/init_ops.py", line 98, in _initializer return random_ops.random_uniform(shape, minval, maxval, dtype, seed=seed) File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/ops/random_ops.py", line 172, in random_uniform shape = _ShapeTensor(shape) File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/ops/random_ops.py", line 45, in _ShapeTensor return ops.convert_to_tensor(shape, dtype=dtype, name="shape") File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/framework/ops.py", line 620, in convert_to_tensor ret = conversion_func(value, dtype=dtype, name=name, as_ref=as_ref) File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/ops/constant_op.py", line 179, in _constant_tensor_conversion_function return constant(v, dtype=dtype, name=name) File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/ops/constant_op.py", line 162, in constant tensor_util.make_tensor_proto(value, dtype=dtype, shape=shape)) File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/framework/tensor_util.py", line 421, in make_tensor_proto tensor_proto.string_val.extend([compat.as_bytes(x) for x in proto_values]) File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/framework/tensor_util.py", line 421, in tensor_proto.string_val.extend([compat.as_bytes(x) for x in proto_values]) File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/util/compat.py", line 44, in as_bytes raise TypeError('Expected binary or unicode string, got %r' % bytes_or_text) TypeError: Expected binary or unicode string, got < map object at 0x7f22129d3e10 >

vrodionovpro commented 8 years ago

Compiling fine on keras 1.0.5 https://pypi.python.org/pypi/Keras/1.0.5