Input 2D matrices and Ouptut scalar #139
-
Hello! I am new to TensorFlow, so please mind the lack of knowledge. I decided to start a project to improve my skills in which I need to create a model which takes 2D matrixes and outputs scalars. So I just created my array of 2D matrices
But I just cant figure out how keras works with layers and I always end up with layers that cant output a scalar. I tried changing the input shape but with no success. As expected, if I do Thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
Hey @papipopapu I think you may be looking for something like a Flatten layer, it will condense your outputs at the end.
|
Beta Was this translation helpful? Give feedback.
-
I was going to answer something very similar to @ashikshafi08! You could also try the Flatten layer at the start of the network: #1
model_1 = tf.keras.Sequential([
tf.keras.layers.Flatten(), # Add the flatten layer in here
tf.keras.layers.Dense(100),
tf.keras.layers.Dense(10),
tf.keras.layers.Dense(1, activation = "relu")
])
#2
model_1.compile(optimizer=tf.optimizers.Adam(), loss=tf.keras.losses.mae)
#3
history = model_1.fit(X_train, y_train, epochs=100, callbacks=[callback]) Give it a try and let us know how you go. |
Beta Was this translation helpful? Give feedback.
Hey @papipopapu
I think you may be looking for something like a Flatten layer, it will condense your outputs at the end.