Quantcast
Channel: Data Science, Analytics and Big Data discussions - Latest topics
Viewing all articles
Browse latest Browse all 4448

Neural Networks - error clarification

$
0
0

@mosrihari wrote:

Hi Everyone,
I am new to Deep Learning and I tried some code with Deep Learning techniques to predict the categories of the text. Please find the specifications of dataframe below.

  1. Stopwords, punctuations and tolower are done to all the text and it is now in bag of words format
  2. Many aspect Terms are one hot encoded.
    aspectTerm=pd.get_dummies(aspect[“Aspect.Terms”])
    print(aspectTerm)
    from sklearn.model_selection import train_test_split
    from sklearn.svm import SVC
    aspect=pd.concat([aspect,aspectTerm],axis=1)
  3. There are totally 9 aspect categories (Target)

Input dataframe shape:(2801, 2431)
Target dataframe unique categories: 9
I tried using very simple ANN in Keras as below:

classifier=Sequential()
#We will start adding layers Adding the input layer and one hidden layer
classifier.add(Dense(units=1220,kernel_initializer=‘uniform’,activation=‘relu’,input_dim=2431)) #output_dim is chosen (11 input+1 output)/2
classifier.add(Dropout(rate=0.1))
#input dim is mandatory in the beginning
classifier.add(Dense(units=8,kernel_initializer=‘uniform’,activation=‘sigmoid’))
#Going to apply stochastic gradient descent to the ANN
classifier.compile(optimizer=‘adam’,loss=‘binary_crossentropy’,metrics=[‘accuracy’])

classifier.fit(X_train,y_train,batch_size=1000,epochs=3)

But I am getting the following error:
ValueError: Error when checking target: expected dense_14 to have shape (8,) but got array with shape (1,)

Could you please advice on the above ?

Thank you in advance

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 4448

Trending Articles