Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

How do I fix my BiLSTM code in R? x_test and y_test are dimension 1 529, post padding sequences. The rest should be 1 2114,

How do I fix my BiLSTM code in R?

x_test and y_test are dimension 1 529, post padding sequences. The rest should be 1 2114, again post padding sequences. Consistently running into different issues.

bilstm_mod <- keras_model_sequential() %>% layer_embedding(input_dim = 23, output_dim = 23) %>% bidirectional(layer_lstm(units = 32, dropout = 0.4, recurrent_dropout = 0.4)) %>% layer_dense(units = 23, activation = "sigmoid")

bilstm_mod %>% compile( optimizer = "adam", loss = "binary_crossentropy", metrics = c("accuracy") )

Index<-c(1:length(returned_mean)) split<-0.8*length(returned_mean) x_train <- c(Index[1:round(split)]) x_test <- Index[round(split):length(returned_mean)] y_train_rm <- returned_mean[1:round(split)] y_test_rm <- returned_mean[round(split):length(returned_mean)] y_train_vv<-variance_vector[1:round(split)] y_test_vv <- variance_vector[round(split):length(returned_mean)] y_train_mr<-mean_returns[1:round(split)] y_test_mr <- mean_returns[round(split):length(returned_mean)]

x_train<-pad_sequences(list(x_train),max=23) y_train_vv<-pad_sequences(list(y_train_vv),max=23) y_train_rm<-pad_sequences(list(y_train_rm),max=23) y_train_mr<-pad_sequences(list(y_train_mr),max=23) y_test_vv<-pad_sequences(list(y_test_vv),max=23) y_test_rm<-pad_sequences(list(y_test_rm),max=23) y_test_mr<-pad_sequences(list(y_test_mr),max=23) x_test<-pad_sequences(list(x_test),max=23)

bilstm_mod %>% fit( x_train, y_train_rm, batch_size = 23, epochs = 4, validation_data = list(x_test, y_test_rm) )

bilstm_mod %>% evaluate(x_train, y_train_rm) bilstm_mod %>% evaluate(x_test, y_test_rm)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Modern Database Management

Authors: Jeff Hoffer, Ramesh Venkataraman, Heikki Topi

13th Edition Global Edition

1292263350, 978-1292263359

More Books

Students also viewed these Databases questions