titu1994/keras-coordconv

ValueError: setting an array element with a sequence

socathie opened this issue · 2 comments

This is the beginning of my network.

X = Input(shape=(x,y,z,1))
out = CoordinateChannel3D()(X)
out = ...

while x,y,z are some predefined dimensions, x!=y!=z.

when I try to compile, I get the following error:

~\Anaconda3\lib\site-packages\keras\engine\topology.py in __call__(self, inputs, **kwargs)
    601 
    602             # Actually call the layer, collecting output(s), mask(s), and shape(s).
--> 603             output = self.call(inputs, **kwargs)
    604             output_mask = self.compute_mask(inputs, previous_mask)
    605 

~\Documents\GitHub\decoding-fmri\cnn\coord.py in call(self, inputs, training, mask)
    141             batch_shape, dim1, dim2, dim3, channels = input_shape
    142 
--> 143             xx_ones = K.ones(K.stack([batch_shape, dim3]), dtype='int32')
    144             xx_ones = K.expand_dims(xx_ones, axis=-1)
    145 

~\Anaconda3\lib\site-packages\keras\backend\tensorflow_backend.py in ones(shape, dtype, name)
    697         dtype = floatx()
    698     tf_dtype = tf.as_dtype(dtype)
--> 699     return variable(tf.constant_initializer(1., dtype=tf_dtype)(shape),
    700                     dtype, name)
    701 

~\Anaconda3\lib\site-packages\tensorflow\python\ops\init_ops.py in __call__(self, shape, dtype, partition_info, verify_shape)
    215       verify_shape = self._verify_shape
    216     return constant_op.constant(
--> 217         self.value, dtype=dtype, shape=shape, verify_shape=verify_shape)
    218 
    219   def get_config(self):

~\Anaconda3\lib\site-packages\tensorflow\python\framework\constant_op.py in constant(value, dtype, shape, name, verify_shape)
    212   tensor_value.tensor.CopyFrom(
    213       tensor_util.make_tensor_proto(
--> 214           value, dtype=dtype, shape=shape, verify_shape=verify_shape))
    215   dtype_value = attr_value_pb2.AttrValue(type=tensor_value.tensor.dtype)
    216   const_tensor = g.create_op(

~\Anaconda3\lib\site-packages\tensorflow\python\framework\tensor_util.py in make_tensor_proto(values, dtype, shape, verify_shape)
    428     # If shape is None, numpy.prod returns None when dtype is not set, but raises
    429     # exception when dtype is set to np.int64
--> 430     if shape is not None and np.prod(shape, dtype=np.int64) == 0:
    431       nparray = np.empty(shape, dtype=np_dt)
    432     else:

~\Anaconda3\lib\site-packages\numpy\core\fromnumeric.py in prod(a, axis, dtype, out, keepdims)
   2564 
   2565     return _methods._prod(a, axis=axis, dtype=dtype,
-> 2566                           out=out, **kwargs)
   2567 
   2568 

~\Anaconda3\lib\site-packages\numpy\core\_methods.py in _prod(a, axis, dtype, out, keepdims)
     33 
     34 def _prod(a, axis=None, dtype=None, out=None, keepdims=False):
---> 35     return umr_prod(a, axis, dtype, out, keepdims)
     36 
     37 def _any(a, axis=None, dtype=None, out=None, keepdims=False):

ValueError: setting an array element with a sequence.

Any idea where does this error arise?

Sorry for the late reply. Could you try with the latest version of the script ?

I re-cloned the script and the error disappears. Thanks.