I am using a tutorial on youtube. I took my own spin on it and although the code is essentially identical, I am getting an error message saying that the found shape does not match input shape
ValueError: Input 0 of layer "sequential" is incompatible with the layer: expected shape=(None, 621, 17), found shape=(None, 17)
The code leading to this looks like this
import pandas as pd
from sklearn.model_selection import train_test_split
import tensorflow as tf
datasetFull = pd.read_csv('College_Data.csv')
dataset = datasetFull.drop("Name", axis=1)
x = dataset.drop("Private", axis=1)
y = dataset["Private"]
y.replace('Yes', 1)
y.replace('No', 0)
x_train, x_test, y_train, y_test = train_test_split(x, y, test_size=0.2)
print(x_train.shape)
model = tf.keras.models.Sequential()
model.add(tf.keras.layers.Dense(256, input_shape=x_train.shape, activation='sigmoid'))
model.add(tf.keras.layers.Dense(256, activation='sigmoid'))
model.add(tf.keras.layers.Dense(1, activation='sigmoid'))
model.compile(optimizer='adam', loss='binary_crossentropy', metrics=['accuracy'])
tf.reshape(x_train, [621, 17])
print(x_train.shape)
model.fit(x_train, y_train, epochs=1000)
Not sure if this is relevant, but I also get error messages like this that do not seem to actually stop the process.
This TensorFlow binary is optimized to use available CPU instructions in performance-critical operations.
To enable the following instructions: SSE SSE2 SSE3 SSE4.1 SSE4.2 AVX AVX2 FMA, in other operations, rebuild TensorFlow with the appropriate compiler flags.
As you can see, I tried to print
the shape of the input data before I take it as the input shape and before I submit it to fit
I also tried reshaping the input data right before submitting it to Keras with tf.reshape(x_train, [621, 17])
No matter what I did/do the same error always comes up:
ValueError: Input 0 of layer "sequential" is incompatible with the layer: expected shape=(None, 621, 17), found shape=(None, 17)