GRUV icon indicating copy to clipboard operation
GRUV copied to clipboard

Exception: Layer timedistributeddense_1 requires to know the length of its input, but it could not be inferred automatically.

Open andrenajp opened this issue 8 years ago • 7 comments

Using TensorFlow backend. Loading training data Finished loading training data /usr/lib/python2.7/dist-packages/keras/layers/core.py:1112: UserWarning: TimeDistributedDense is deprecated, please use TimeDistributed(Dense(...)) instead. warnings.warn('TimeDistributedDense is deprecated, ' Traceback (most recent call last): File "train.py", line 27, in model = network_utils.create_lstm_network(num_frequency_dimensions=freq_space_dims, num_hidden_dimensions=hidden_dims) File "/home/andrena/Bureau/GRUV-master/nn_utils/network_utils.py", line 8, in create_lstm_network model.add(TimeDistributedDense(input_dim=num_frequency_dimensions, output_dim=num_hidden_dimensions)) File "/usr/lib/python2.7/dist-packages/keras/models.py", line 276, in add layer.create_input_layer(batch_input_shape, input_dtype) File "/usr/lib/python2.7/dist-packages/keras/engine/topology.py", line 370, in create_input_layer self(x) File "/usr/lib/python2.7/dist-packages/keras/engine/topology.py", line 514, in call self.add_inbound_node(inbound_layers, node_indices, tensor_indices) File "/usr/lib/python2.7/dist-packages/keras/engine/topology.py", line 572, in add_inbound_node Node.create_node(self, inbound_layers, node_indices, tensor_indices) File "/usr/lib/python2.7/dist-packages/keras/engine/topology.py", line 149, in create_node output_tensors = to_list(outbound_layer.call(input_tensors[0], mask=input_masks[0])) File "/usr/lib/python2.7/dist-packages/keras/layers/core.py", line 1185, in call ' requires to know the length of its input, ' Exception: Layer timedistributeddense_1 requires to know the length of its input, but it could not be inferred automatically. Specify it manually by passing an input_shape argument to the first layer in your model.

andrenajp avatar Oct 06 '16 15:10 andrenajp

Hi, I have the same error :( dataset is 3 files, two of them are 1 hour long, and one have 3 minutes

piteight avatar Oct 25 '16 12:10 piteight

My output: Using TensorFlow backend. I tensorflow/stream_executor/dso_loader.cc:111] successfully opened CUDA library libcublas.so locally I tensorflow/stream_executor/dso_loader.cc:111] successfully opened CUDA library libcudnn.so locally I tensorflow/stream_executor/dso_loader.cc:111] successfully opened CUDA library libcufft.so locally I tensorflow/stream_executor/dso_loader.cc:111] successfully opened CUDA library libcuda.so.1 locally I tensorflow/stream_executor/dso_loader.cc:111] successfully opened CUDA library libcurand.so locally Loading training data Finished loading training data /home/basia/keras/keras/layers/core.py:1112: UserWarning: TimeDistributedDense is deprecated, please use TimeDistributed(Dense(...)) instead. warnings.warn('TimeDistributedDense is deprecated, ' I tensorflow/stream_executor/cuda/cuda_gpu_executor.cc:925] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero I tensorflow/core/common_runtime/gpu/gpu_device.cc:951] Found device 0 with properties: name: GeForce GTX 750 major: 5 minor: 0 memoryClockRate (GHz) 1.137 pciBusID 0000:01:00.0 Total memory: 1.95GiB Free memory: 1.72GiB I tensorflow/core/common_runtime/gpu/gpu_device.cc:972] DMA: 0 I tensorflow/core/common_runtime/gpu/gpu_device.cc:982] 0: Y I tensorflow/core/common_runtime/gpu/gpu_device.cc:1041] Creating TensorFlow device (/gpu:0) -> (device: 0, name: GeForce GTX 750, pci bus id: 0000:01:00.0) Traceback (most recent call last): File "train.py", line 27, in model = network_utils.create_lstm_network(num_frequency_dimensions=freq_space_dims, num_hidden_dimensions=hidden_dims) File "/media/basia/4e262056-f01f-4d05-a453-9e58b9a1a8da/GRUV/nn_utils/network_utils.py", line 8, in create_lstm_network model.add(TimeDistributedDense(input_dim=num_frequency_dimensions, output_dim=num_hidden_dimensions)) File "/home/basia/keras/keras/models.py", line 276, in add layer.create_input_layer(batch_input_shape, input_dtype) File "/home/basia/keras/keras/engine/topology.py", line 370, in create_input_layer self(x) File "/home/basia/keras/keras/engine/topology.py", line 514, in call self.add_inbound_node(inbound_layers, node_indices, tensor_indices) File "/home/basia/keras/keras/engine/topology.py", line 572, in add_inbound_node Node.create_node(self, inbound_layers, node_indices, tensor_indices) File "/home/basia/keras/keras/engine/topology.py", line 149, in create_node output_tensors = to_list(outbound_layer.call(input_tensors[0], mask=input_masks[0])) File "/home/basia/keras/keras/layers/core.py", line 1185, in call ' requires to know the length of its input, ' Exception: Layer timedistributeddense_1 requires to know the length of its input, but it could not be inferred automatically. Specify it manually by passing an input_shape argument to the first layer in your model.

piteight avatar Oct 26 '16 10:10 piteight

Solution is downgrading keras to version 0.1.0 . :) Newest keras have some changes in naming and using timedistributedense and other stuff. I'm new to keras stuff, but i think it might be easily changed in nn_utils, where this network parameters are described.

piteight avatar Oct 28 '16 10:10 piteight

I am setting up my system and currently having the same issue. @piteight Are you using Theano or TensorFlow with keras version 0.1.0 ? I have TensorFlow installed but after doing the "sudo python setup.py install" I get an import error saying no module named keras.modules.

akgun1 avatar Nov 01 '16 01:11 akgun1

Meybe this will work pip install https://github.com/fchollet/keras/tarball/0.1.0 Im using Theano, beacuse I read, that GRUV isnt compatibile with TensorFlow right now.

piteight avatar Nov 03 '16 01:11 piteight

@piteight Thank you, it seems to be working now.

I uninstalled keras and re-installed using piteight's solution. Also, I switched Keras's backend from the default TensorFlow to Theano (instructions here: https://keras.io/backend/).

akgun1 avatar Nov 03 '16 17:11 akgun1

For those who want to use Keras version 1.1.1 (currently the latest, as of 11/12/16) then you can adopt the changes in my repo: https://github.com/mattpearson/GRUV

mattpearson avatar Nov 13 '16 00:11 mattpearson