Keras Input~Output dimensions


I have two data sets (matrices) that contains 1x Input and 5x Outputs.

x_data is a matrix [1,1:200]
y_data is a matrix [200,1:5]

Bellow the model i used (did't work due to error):

model = keras_model_sequential() %>%   
  layer_dense(units = 64, activation = "relu", input_shape = ncol(x_data)) %>%
  layer_dense(units = 64, activation = "relu") %>%
  layer_dense(units = nrow(y_data), activation = "softmax")

compile(model, loss = "categorical_crossentropy", optimizer = optimizer_rmsprop(), metrics = "accuracy")

fitmodel = fit(model,  x_data, y_data, epochs = 20, batch_size = 10, validation_split = 0.2)

Can you please explain what i am doing wrong?

Thank you in advance

Could you please turn this into a self-contained reprex (short for reproducible example)? It will help us help you if we can be sure we're all working with/looking at the same stuff. For example, it's much easier to diagnose an error if we have the actual error message in front of us, and can see where it pops up in the code execution.


If you've never heard of a reprex before, you might want to start by reading the help page. The reprex dos and don'ts are also useful.

What to do if you run into clipboard problems

If you run into problems with access to your clipboard, you can specify an outfile for the reprex, and then copy and paste the contents into the forum.

reprex::reprex(input = "fruits_stringdist.R", outfile = "")

For pointers specific to the community site, check out the reprex FAQ.

1 Like

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.