1

I have created the following model graph for my training:

n_steps = 9
n_inputs = 6
n_neurons = 50
n_outputs = 1
n_layers = 2
learning_rate = 0.0001
batch_size =100
n_epochs = 1000#200 
train_set_size = 100
test_set_size = 100
tf.reset_default_graph()
X = tf.placeholder(tf.float32, [None, n_steps, n_inputs],name="input")
y = tf.placeholder(tf.float32, [None, n_outputs],name="output")
layers = [tf.contrib.rnn.LSTMCell(num_units=n_neurons,activation=tf.nn.relu6, use_peepholes = True,name="layer"+str(layer))
         for layer in range(n_layers)]    
multi_layer_cell = tf.contrib.rnn.MultiRNNCell(layers)
multi_layer_cell_back = tf.contrib.rnn.MultiRNNCell(layers)
rnn_outputs, states = tf.nn.bidirectional_dynamic_rnn(multi_layer_cell,multi_layer_cell_back, X, dtype=tf.float32)
stacked_rnn_outputs = tf.reshape(rnn_outputs, [-1, n_neurons]) 
stacked_outputs = tf.layers.dense(stacked_rnn_outputs, n_outputs)
outputs = tf.reshape(stacked_outputs, [-1, n_steps, n_outputs])
outputs = outputs[:,n_steps-1,:]

Getting the following error:

InvalidArgumentError: Incompatible shapes: [100,1] vs. [200,1]
     [[node hinge_loss/Mul_1 (defined at <ipython-input-146-2bba8c1ac0ac>:45)  = Mul[T=DT_FLOAT, _device="/job:localhost/replica:0/task:0/device:CPU:0"](hinge_loss/Sub, strided_slice)]]

Please let me know what I have missed.

Jaffer Wilson
  • 7,029
  • 10
  • 62
  • 139
  • I noticed that in your original post, `layers.append` was attached to the end of the layers definition (meaning it was right after the ']' character) can you verify that 1) the edited version is correct and 2) that this was intentional? – IanQ Jan 28 '19 at 16:51
  • @IanQuah Sorry I don't know where from that line I have entered in the code. Let me correct it. That line is not there in the code, because it was in the previous version. The latest one is simple. – Jaffer Wilson Jan 29 '19 at 05:58
  • I have edited the code. Please check it out once and let me know. – Jaffer Wilson Jan 29 '19 at 05:59
  • Is there any solution for this? – Jaffer Wilson Jan 29 '19 at 07:54
  • I do not get any error. Strange, it is! But if it would help, [this](https://stackoverflow.com/a/50552539/1757224) answer helped me a lot. – ARAT Jan 29 '19 at 16:25
  • Thank you for helping sir. I am looking at the reference you have provided. – Jaffer Wilson Jan 30 '19 at 04:35

0 Answers0