Skip to main content
. 2022 Dec 3;22(23):9451. doi: 10.3390/s22239451
Listing 1 TensorFlow Keras script for RNN implementation
  • 1:

    verbose = 0                                                                                                                 ▹ data presentation off

  • 2:

    epochs = 40                                                                                                     ▹ maximal number of epochs

  • 3:

    batch_size = 64       ▹ number of samples that will be propagated through the network

  • 4:

    n_timesteps, n_features, n_outputs = trainX.shape[1], trainX.shape[2], trainy.shape[1]

  • 5:

    model = Sequential()

  • 6:

    model.add(LSTM(60, input_shape=(n_timesteps,n_features)))

  • 7:

    model.add(Dropout(0.5))

  • 8:

    model.add(Dense(60, activation=’relu’))

  • 9:

    model.add(Dense(n_outputs, activation=’softmax’))

  • 10:

    model.compile(loss=’categorical_crossentropy’,

                       optimizer=’adam’,

                       metrics=[’accuracy’])