I am trying to do Text Classification using keras, I have preprocessed the text properly removed stopwords, stemmed them, removed punctuation, created Document Term Matrix, The part where i am confused is can i use DTM to directly train my model ? I am getting a very weird error that i am not able to get through
model <- keras_model_sequential()
model %>%
layer_dense(units = 256, activation = 'relu', input_shape = c(784)) %>%
layer_dropout(rate = 0.4) %>%
layer_dense(units = 128, activation = 'relu') %>%
layer_dropout(rate = 0.3) %>%
layer_dense(units = 10, activation = 'softmax')
model %>% compile(
loss = 'categorical_crossentropy',
optimizer = optimizer_rmsprop(),
metrics = c('accuracy')
)
history <- model %>% fit(
dtm_train_most_frequent, train_labels,
epochs = 30, batch_size = 128,
validation_split = 0.2
)
The error i am getting is
Error in UseMethod("fit") :
no applicable method for 'fit' applied to an object of class "c('keras.engine.sequential.Sequential', 'keras.engine.training.Model', 'keras.engine.network.Network', 'keras.engine.base_layer.Layer', 'python.builtin.object')"
I am using R