In the below code:
I get an error when I do not specify the input shape in the $1^{st}$ layer. I thought that TensorFlow can infer the shape for the dense layer. For some code I have seen, TensorFlow works without the input shape specified.
What is the input shape I should specify? X is (9, ). By default, am I supposed to omit the sample size for the input shape?
import numpy as np from numpy import array import pandas as pd from tensorflow.keras.layers import Activation, Dense, SimpleRNN, GRU, LSTM, Conv1D, Conv2D, MaxPool2D, RepeatVector, TimeDistributed X = [1, 2, 3, 4, 5, 6, 8, 9, 10] Y = [10, 15,20, 25, 30, 35, 45, 50, 55] sample_size=len(X) X = np.array(X).reshape(9, ) Y = np.array(Y).reshape(9, ) print(X.shape) model = Sequential() #model.add(Dense(100,input_shape=[1])) model.add(Dense(100)) model.add(Dense(1)) model.compile(loss='mean_squared_error', optimizer='adam') model.fit(X, Y, epochs=500, batch_size=sample_size, verbose=1) ```
Sequential
model requires aninput_shape
argument, so that it can infer the shapes of the trainable parameters like weights and biases.$\endgroup$