lstm

Unknown error/crash – TensorFlow LSTM with GPU (no output after start of 1st epoch)

Unknown error/crash – TensorFlow LSTM with GPU (no output after start of 1st epoch) Question: I’m trying to train a model using LSTM layers. I’m using a GPU and all needed libraries are loaded. When I’m building the model this way: model = keras.Sequential() model.add(layers.LSTM(256, activation="relu", return_sequences=False)) # note the activation function model.add(layers.Dropout(0.2)) model.add(layers.Dense(256, activation="relu")) …

Total answers: 2

How to implement a CNN-LSTM using Keras

How to implement a CNN-LSTM using Keras Question: I am attempting to implement a CNN-LSTM that classifies mel-spectrogram images representing the speech of people with Parkinson’s Disease/Healthy Controls. I am trying to implement a pre-existing model (DenseNet-169) with an LSTM model, however I am running into the following error: ValueError: Input 0 of layer zero_padding2d …

Total answers: 1

Tensorflow – Decoder for Machine Translation

Tensorflow – Decoder for Machine Translation Question: I am going through Tensorflow’s tutorial on Neural Machine Translation using Attention mechanism. It has the following code for the Decoder : class Decoder(tf.keras.Model): def __init__(self, vocab_size, embedding_dim, dec_units, batch_sz): super(Decoder, self).__init__() self.batch_sz = batch_sz self.dec_units = dec_units self.embedding = tf.keras.layers.Embedding(vocab_size, embedding_dim) self.gru = tf.keras.layers.GRU(self.dec_units, return_sequences=True, return_state=True, recurrent_initializer=’glorot_uniform’) …

Total answers: 1

How to make R2 score in nn.LSTM pytorch

How to make R2 score in nn.LSTM pytorch Question: I tried to make loss function with R2in nn.LSTM but i couldnt find any documentation about it . I already use RMSE and MAE loss from pytorch. My data is a time series and im doing time series forecasting This is the code where i use …

Total answers: 2

Why are there 3 losses BUT 2 accuracies in Keras LSTM training?

Why are there 3 losses BUT 2 accuracies in Keras LSTM training? Question: My model is like this: def _get_model(input_shape, latent_dim, num_classes): inputs = Input(shape=input_shape) lstm_lyr,state_h,state_c = LSTM(latent_dim,dropout=0.1,return_state = True)(inputs) fc_lyr = Dense(num_classes)(lstm_lyr) soft_lyr = Activation(‘relu’)(fc_lyr) model = Model(inputs, [soft_lyr,state_c]) model.compile(optimizer=’adam’, loss=’mse’, metrics=[‘accuracy’]) return model model =_get_model((n_steps_in, n_features),latent_dim ,n_steps_out) history = model.fit(X_train,Y_train) during training I …

Total answers: 1

Dimensions between embedding layer and lstm encoder layer don't match

Dimensions between embedding layer and lstm encoder layer don't match Question: I am trying to build an encoder-decoder model for text generation. I am using LSTM layers with an embedding layer. I have somehow a problem with the output of the embedding layer to the LSTM encoder layer. The error I get is: ValueError: Input …

Total answers: 1

CNN-LSTM Timeseries input for TimeDistributed layer

CNN-LSTM Timeseries input for TimeDistributed layer Question: I created a CNN-LSTM for survival prediction of web sessions, my training data looks as follows: print(x_train.shape) (288, 3, 393) with (samples, timesteps, features) and my model: model = Sequential() model.add(TimeDistributed(Conv1D(128, 5, activation=’relu’), input_shape=(x_train.shape[1], x_train.shape[2]))) model.add(TimeDistributed(MaxPooling1D())) model.add(TimeDistributed(Flatten())) model.add(LSTM(64, stateful=True, return_sequences=True)) model.add(LSTM(16, stateful=True)) model.add(Dense(1, activation=’sigmoid’)) model.compile(optimizer=Adam(lr=0.001), loss=’binary_crossentropy’, metrics=[‘accuracy’]) However, …

Total answers: 1

Encoder-Decoder LSTM model gives 'nan' loss and predictions

Encoder-Decoder LSTM model gives 'nan' loss and predictions Question: I am trying to create a basic encoder-decoder model for training a chatbot. X contains the questions or human dialogues and Y contains the bot answers. I have padded the sequences to the max size of input and output sentences. X.shape = (2363, 242, 1) and …

Total answers: 1

Adding Attention on top of simple LSTM layer in Tensorflow 2.0

Adding Attention on top of simple LSTM layer in Tensorflow 2.0 Question: I have a simple network of one LSTM and two Dense layers as such: model = tf.keras.Sequential() model.add(layers.LSTM(20, input_shape=(train_X.shape[1], train_X.shape[2]))) model.add(layers.Dense(20, activation=’sigmoid’)) model.add(layers.Dense(1, activation=’sigmoid’)) model.compile(loss=’mean_squared_error’) It is training on data with 3 inputs (normalized 0 to 1.0) and 1 output (binary) for the …

Total answers: 2