Tensorflow create model

tell me how to roughly assemble the model

input data

Xt = [# only one 1 in an element of 5 values
[[0,0,0,0,1], [0,0,1,0,0], [0,0,0,0,1], [1,0,0,0,0], [ 0,0,1,0,0], [0,0,1,0,0]], 1 (6 elements)

… …
[[0,0,0,0,1], [0,0,0,0,1], [0,0,0,0,1], [0,0,0,0,1], [ 0,0,0,0,1], [0,0,1,0,0]] 500 (6 elements)

Yt = [# only one 1 in an element of 5 values
[[0,0,0,0,1], [0,0,1,0,0], [0,0,0,0,1]], 1 (3 elements)

… …
[[0,0,0,0,1], [0,0,0,0,1], [0,0,0,0,1]] 500 (3 elements)

DOES NOT WORK

act = ‘relu’
model = Sequential ()
model.add (LSTM (6, activation = act, batch_input_shape = (500, 6, 5), return_sequences = True))
model.add (LSTM (3, activation = ‘softmax’)) # assuming this is the last layer
model.compile (optimizer = ‘adam’, loss = ‘categorical_crossentropy’, metrics = [‘acc’])
md = model.fit (Xt, Yt, epochs = 500, batch_size = 500, verbose = 1, shuffle = False)

ValueError: Shapes (500, 6, 5) and (500, 3) are incompatible

Hi, Saha. You can add more details about your problem and data so we can see where to help.

As you are using softmax activation in the last layer, Your code is expecting Yt to be of size [500, 3] where as you are providing an array of size [500,3,5]. When I updated your code with that change, model trains without any error. Please note that the data I am using is only for demonstration.

Here is a gist for reference. Thanks!

Check this example for more details.