sergiooramas / tartarus

Deep Learning for audio and text
MIT License
101 stars 26 forks source link

which version of tensorflow do you use in the project? #3

Open chenjie04 opened 6 years ago

chenjie04 commented 6 years ago

when I run you code on my machine with keras==1.1.0 and tensorflow==1.0.0, I catch the error as below: Traceback (most recent call last): File "run_experiments.py", line 343, in process(params) File "/home/jie_chen/recommendation/tartarus/src/train.py", line 322, in process model = build_model(config) File "/home/jie_chen/recommendation/tartarus/src/train.py", line 68, in build_model model = get_model(params) File "/home/jie_chen/recommendation/tartarus/src/models.py", line 160, in get_model_1 model.add(Flatten()) File "/home/jie_chen/tensorflow11/local/lib/python2.7/site-packages/keras/models.py", line 308, in add output_tensor = layer(self.outputs[0]) File "/home/jie_chen/tensorflow11/local/lib/python2.7/site-packages/keras/engine/topology.py", line 514, in call self.add_inbound_node(inbound_layers, node_indices, tensor_indices) File "/home/jie_chen/tensorflow11/local/lib/python2.7/site-packages/keras/engine/topology.py", line 572, in add_inbound_node Node.create_node(self, inbound_layers, node_indices, tensor_indices) File "/home/jie_chen/tensorflow11/local/lib/python2.7/site-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 "/home/jie_chen/tensorflow11/local/lib/python2.7/site-packages/keras/layers/core.py", line 409, in call return K.batch_flatten(x) File "/home/jie_chen/tensorflow11/local/lib/python2.7/site-packages/keras/backend/tensorflow_backend.py", line 823, in batch_flatten x = tf.reshape(x, tf.pack([-1, prod(shape(x)[1:])])) AttributeError: 'module' object has no attribute 'pack'

As far as I know, the tf.pack() has renamed as tf.stack(). So ,what can I do to fix the problem? to update the keras? please help! thanks!

sergiooramas commented 6 years ago

I basically used Theano, so I'm not sure what happens with tensorflow and my code. You can also run the code with Keras 2, you can try that.

chenjie04 commented 6 years ago

thank you very much! I will try that now.

chenjie04 commented 6 years ago

hello! I update the Keras(2.1.5) and tensorflow(1.7.0), but it throw out another error :ValueError: Error when checking target: expected activation_3 to have shape (3,) but got array with shape (1,).

The detail show as follow: Traceback (most recent call last): File "run_experiments.py", line 343, in process(params) File "/home/jie_chen/recommendation/tartarus/src/train.py", line 397, in process callbacks=[early_stopping]) File "/home/jie_chen/tensorflow11/local/lib/python2.7/site-packages/keras/legacy/interfaces.py", line 91, in wrapper return func(*args, *kwargs) File "/home/jie_chen/tensorflow11/local/lib/python2.7/site-packages/keras/models.py", line 1276, in fit_generator initial_epoch=initial_epoch) File "/home/jie_chen/tensorflow11/local/lib/python2.7/site-packages/keras/legacy/interfaces.py", line 91, in wrapper return func(args, kwargs) File "/home/jie_chen/tensorflow11/local/lib/python2.7/site-packages/keras/engine/training.py", line 2160, in fit_generator val_x, val_y, val_sample_weight) File "/home/jie_chen/tensorflow11/local/lib/python2.7/site-packages/keras/engine/training.py", line 1480, in _standardize_user_data exception_prefix='target') File "/home/jie_chen/tensorflow11/local/lib/python2.7/site-packages/keras/engine/training.py", line 123, in _standardize_input_data str(data_shape)) ValueError: Error when checking target: expected activation_3 to have shape (3,) but got array with shape (1,)** And the summary as this:


Layer (type) Output Shape Param #

conv2d_1 (Conv2D) (None, 64, 319, 1) 24640


activation_1 (Activation) (None, 64, 319, 1) 0


max_pooling2d_1 (MaxPooling2 (None, 64, 79, 1) 0


dropout_1 (Dropout) (None, 64, 79, 1) 0


conv2d_2 (Conv2D) (None, 128, 76, 1) 32896


activation_2 (Activation) (None, 128, 76, 1) 0


max_pooling2d_2 (MaxPooling2 (None, 128, 38, 1) 0


dropout_2 (Dropout) (None, 128, 38, 1) 0


flatten_1 (Flatten) (None, 4864) 0


dense_1 (Dense) (None, 3) 14595


activation_3 (Activation) (None, 3) 0

Total params: 72,131 Trainable params: 72,131 Non-trainable params: 0


I can't find any solution on the Internet. please help me, thank you! and I add K.set_image_dim_ordering('th') in models.py, is it cause the problem?