Following my Studies in Machine learning I am now in the Neural network, I have an assignment - text Classification - using Neural Network.
In the following, I am showing what I have so far
Now I'm trying to compile the NN However I am receiving the following error
TypeError: 'SparseTensor' object is not subscriptable Traceback (most recent call last): File "/opt/conda/lib/python3.7/site-packages/tensorflow/python/ops/script_ops.py", line 242, in call return func(device, token, args) File "/opt/conda/lib/python3.7/site-packages/tensorflow/python/ops/script_ops.py", line 131, in call
My data shape is the following
X_train.shape = (17621, 8014)
type(X_train) = scipy.sparse.csr.csr_matrix
The model
model = Sequential()
model.add(Dense(1015, input_shape=(17621, 8014) , activation = 'relu'))
model.add(Dense(5, activation = 'sigmoid'))
model.add(Dense(1,activation='sigmoid'))
model.compile(loss = 'binary_crossentropy',metrics = ['accuracy'], optimizer = 'adam')
model.fit(x=X_train, y=y_train,epochs=500,batch_size=125,
validation_data=(X_test,y_test))
in addition, I have 2 more question
Please feel free to give more suggestion
Keras can't work with csr_matrix. Convert to a numpy array.
X_train = X_train.toarray()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With