Skip to content

Reshape cannot infer the missing input size for an empty tensor #2

@petteriTeikari

Description

@petteriTeikari

There was a typo also on line 159 of SOCNN.py when trying the shared_final_weights option

out = TimeDistributed(Dense(output_length ...

that I changed to

out = TimeDistributed(Dense(self.output_length ...

And got the training started with:

I tensorflow/core/common_runtime/gpu/gpu_device.cc:975] Creating TensorFlow device (/gpu:0) -> (device: 0, name: GeForce GTX 1070, pci bus id: 0000:01:00.0)
Total model parameters: 7196
---current learning rate: 0.00100000
Epoch 1/1000

But then the following error happend then:

Caused by op 'softmax/Reshape_1', defined at:
  File "nntimeseries/nnts/models/SOCNN.py", line 189, in <module>
    runner.run(SOCNNmodel, log=log, limit=6)
  File "nntimeseries/nnts/utils.py", line 150, in run
    model = model_class(data, params, os.path.join(WDIR, 'tensorboard'))
  File "nntimeseries/nnts/utils.py", line 263, in __init__
    self.nn, self.io_func, self.callbacks = self.build()
  File "nntimeseries/nnts/models/SOCNN.py", line 152, in build
    sig = TimeDistributed(Activation('softmax'), name='softmax')(sig)
  File "anaconda3/lib/python3.6/site-packages/keras/engine/topology.py", line 578, in __call__
    output = self.call(inputs, **kwargs)
  File "anaconda3/lib/python3.6/site-packages/keras/layers/wrappers.py", line 180, in call
    y = K.reshape(y, (-1, input_length) + output_shape[2:])
  File "anaconda3/lib/python3.6/site-packages/keras/backend/tensorflow_backend.py", line 1568, in reshape
    return tf.reshape(x, shape)
  File "anaconda3/lib/python3.6/site-packages/tensorflow/python/ops/gen_array_ops.py", line 2630, in reshape
    name=name)
  File "anaconda3/lib/python3.6/site-packages/tensorflow/python/framework/op_def_library.py", line 763, in apply_op
    op_def=op_def)
  File "anaconda3/lib/python3.6/site-packages/tensorflow/python/framework/ops.py", line 2327, in create_op
    original_op=self._default_original_op, op_def=op_def)
  File "anaconda3/lib/python3.6/site-packages/tensorflow/python/framework/ops.py", line 1226, in __init__
    self._traceback = _extract_stack()

InvalidArgumentError (see above for traceback): Reshape cannot infer the missing input size for an empty tensor unless all specified input sizes are non-zero
	 [[Node: softmax/Reshape_1 = Reshape[T=DT_FLOAT, Tshape=DT_INT32, _device="/job:localhost/replica:0/task:0/gpu:0"](softmax/Softmax, softmax/Reshape_1/shape)]]
	 [[Node: add/_445 = _Recv[client_terminated=false, recv_device="/job:localhost/replica:0/task:0/cpu:0", send_device="/job:localhost/replica:0/task:0/gpu:0", send_device_incarnation=1, tensor_name="edge_10390_add", tensor_type=DT_FLOAT, _device="/job:localhost/replica:0/task:0/cpu:0"]()]]

I guess I have to explicitly set shape for the sig of sig = TimeDistributed(Activation('softmax'), name='softmax')(sig) ?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions