0

I'm having a real problem diagnosing an issue I have with Tensorflow. I get this ValueError and it's not intuitive at all. I've tried converting my floats to np.float32 as specified in other SO questions. I've tried a basket of solutions, but I can't seem to get past it.

My data is in a Pandas dataframe. I joined a TF-IDF dataframe with some other wrangled features to get my final data set. The dimensions are (7176, 1006). I'm using Tensorflow and my model code is:

model = Sequential()

model.add(Dense(500, activation='relu'))
model.add(Conv1D(500, 10, activation='relu', input_shape=input_shape)) # Convultional Layer
model.add(MaxPooling1D(pool_size=10, strides=80)) # MaxPooling
model.add(LSTM(250, dropout=0.2, recurrent_dropout=0.2)) # LSTM Layer
model.add(Dense(111, activation='softmax')) #output layer
model.compile(
    loss='sparse_categorical_crossentropy',
    optimizer='adam',
    metrics=['accuracy']
)

model.fit(X_train, y_train, epochs=10, validation_data=(X_test, y_test))

I've used this data in an AutoKeras model so I'm reasonably sure that the issue is how I've constructed my model (that model never finished, it took way to long). After navigating the inevitable input dimension errors I've arrived here and I want to pull my hair out. Any help or suggestions are greatly appreciated!

1 Answer 1

1

You need to convert your final dataset to numpy array. You can use following method:

import numpy as np
input_data = np.array(your_final_data_array).astype(np.float32)

It should work fine now.

Sign up to request clarification or add additional context in comments.

6 Comments

Some columns in my dataset are strings, but the rest of the values have already been converted.
Strings will need to get encoded. Additionally, you might need to use some form of scaler to scale your data.
Your model doesn't support that input format. You will need encode as pavel already mentioned.
I was afraid I had forgotten something and I think that was definitely it! I will encode my columns and update you guys. Thanks!
after encoding, please convert the final data to numpy
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.