KERAS rookie, did the neural network, found that always reported an error, tried for a few days and did not find out the reason, please give me some advice
import pandas as pd
import numpy as np
import keras
import sklearn
from sklearn import metrics
from sklearn.model_selection import train_test_split
data=pd.read_csv(r"E:\Kaggle\Quora_Insincere_Questions_Classification\train.csv")
x=data["question_text"]
y=data["target"]
train_x,text_x,train_y,text_y=train_test_split(x,y,test_size=0.1,random_state=2019)
tokenizer=keras.preprocessing.text.Tokenizer(num_words=5000000)
tokenizer.fit_on_texts(list(train_x))
train_x=tokenizer.texts_to_sequences(train_x)
text_x=tokenizer.texts_to_sequences(text_x)
train_x=keras.preprocessing.sequence.pad_sequences(train_x,maxlen=100,padding="post")
text_x=keras.preprocessing.sequence.pad_sequences(text_x,maxlen=100,padding="post")
xor=keras.models.Sequential()
xor.add(keras.layers.embeddings.Embedding(input_dim=100,output_dim=1,mask_zero=False))
xor.add(keras.layers.Dense(100000,input_dim=1))
xor.add(keras.layers.pooling.GlobalMaxPool1D())
xor.add(keras.layers.Activation("relu"))
xor.add(keras.layers.Dense(2,activation="sigmoid"))
xor.add(keras.layers.Dense(2))
xor.add(keras.layers.Dense(1))
xor.compile(loss="binary_crossentropy",optimizer="adam",metrics=["accuracy"])
print(xor.summary())
history=xor.fit(train_x,train_y,epochs=100,verbose=0)
score=xor.evaluate(train_x,train_y)
print(score)
contents of
C:UsershaseeAppDataLocalProgramsPythonPython36python.exe E:/pg/Kaggle/Quora/text10.py
Using TensorFlow backend.
Total params: 400111 File "C:UsershaseeAppDataLocalProgramsPythonPython36libsite-packageskerasenginetraining.py", line 1039, in fit File "C:UsershaseeAppDataLocalProgramsPythonPython36libsite-packageskerasenginetraining_arrays.py", line 199, in fit_loop File "C:UsershaseeAppDataLocalProgramsPythonPython36libsite-packageskerasbackendtensorflow_backend.py", line 2715, in call File "C:UsershaseeAppDataLocalProgramsPythonPython36libsite-packageskerasbackendtensorflow_backend.py", line 2675, in _ call File "C:UsershaseeAppDataLocalProgramsPythonPython36libsite-packagestensorflowpythonclientsession.py", line 1439, in call File "C:UsershaseeAppDataLocalProgramsPythonPython36libsite-packagestensorflowpythonframeworkerrors_impl.py", line 528, in exit tensorflow.python.framework.errors_impl.InvalidArgumentError: indices [0jue 2] = 2087 is not in [0100) Process finished with exit code 1
Trainable params: 400111
Non-trainable params: 0
_ strong >
history=xor.fit(train_x,train_y,epochs=100,verbose=0)
validation_steps=validation_steps)
outs = f(ins_batch)
return self._call(inputs)
fetched = self._callable_fn(*array_vals)
run_metadata_ptr)
c_api.TF_GetCode(self.status.status))
[[{{node embedding_1/embedding_lookup}} = GatherV2[Taxis=DT_INT32, Tindices=DT_INT32, Tparams=DT_FLOAT, _class=["loc:@training/Adam/Assign_2"], _device="/job:localhost/replica:0/task:0/device:CPU:0"](embedding_1/embeddings/read, embedding_1/Cast, training/Adam/gradients/embedding_1/embedding_lookup_grad/concat/axis)]]