Let me understand the model

44 views Asked by At

I am dealing with a problem to predict electrical power output using LSTM in R. I found a very suitable code for my data here. But the problem is I do not understand what is meant by

  1. Units
  2. Input_shape
  3. layer_dropout
  4. layer_dropout
  5. loss
  6. adam

below is the code from where I have mentioned list of my question.

    model %>%
  layer_lstm(units = 100,
             input_shape = c(datalags, 2),
             batch_size = batch.size,
             return_sequences = TRUE,
             stateful = TRUE) %>%
  layer_dropout(rate = 0.5) %>%
  layer_lstm(units = 50,
             return_sequences = FALSE,
             stateful = TRUE) %>%
  layer_dropout(rate = 0.5) %>%
  layer_dense(units = 1)

model %>%
  compile(loss = 'mae', optimizer = 'adam')
1

There are 1 answers

0
M.Viking On

These arguments are defined in the reference documentation here:

https://keras.rstudio.com/reference/layer_lstm.html

Arguments object Model or layer object

units Positive integer, dimensionality of the output space.

activation Activation function to use. Default: hyperbolic tangent (tanh). If you pass NULL, no activation is applied (ie. "linear" activation: a(x) = x).

recurrent_activation Activation function to use for the recurrent step.

use_bias Boolean, whether the layer uses a bias vector.

return_sequences Boolean. Whether to return the last output in the output sequence, or the full sequence.

return_state Boolean (default FALSE). Whether to return the last state in addition to the output.

go_backwards Boolean (default FALSE). If TRUE, process the input sequence backwards and return the reversed sequence.

stateful Boolean (default FALSE). If TRUE, the last state for each sample at index i in a batch will be used as initial state for the sample of index i in the following batch.

unroll Boolean (default FALSE). If TRUE, the network will be unrolled, else a symbolic loop will be used. Unrolling can speed-up a RNN, although it tends to be more memory-intensive. Unrolling is only suitable for short sequences.

kernel_initializer Initializer for the kernel weights matrix, used for the linear transformation of the inputs.

recurrent_initializer Initializer for the recurrent_kernel weights matrix, used for the linear transformation of the recurrent state.

bias_initializer Initializer for the bias vector.

unit_forget_bias Boolean. If TRUE, add 1 to the bias of the forget gate at initialization. Setting it to true will also force bias_initializer="zeros". This is recommended in Jozefowicz et al.

kernel_regularizer Regularizer function applied to the kernel weights matrix.

recurrent_regularizer Regularizer function applied to the recurrent_kernel weights matrix.

bias_regularizer Regularizer function applied to the bias vector.

activity_regularizer Regularizer function applied to the output of the layer (its "activation")..

kernel_constraint Constraint function applied to the kernel weights matrix.

recurrent_constraint Constraint function applied to the recurrent_kernel weights matrix.

bias_constraint Constraint function applied to the bias vector.

dropout Float between 0 and 1. Fraction of the units to drop for the linear transformation of the inputs.

recurrent_dropout Float between 0 and 1. Fraction of the units to drop for the linear transformation of the recurrent state.

input_shape Dimensionality of the input (integer) not including the samples axis. This argument is required when using this layer as the first layer in a model.

batch_input_shape Shapes, including the batch size. For instance, batch_input_shape=c(10, 32) indicates that the expected input will be batches of 10 32-dimensional vectors. batch_input_shape=list(NULL, 32) indicates batches of an arbitrary number of 32-dimensional vectors.

batch_size Fixed batch size for layer

dtype The data type expected by the input, as a string (float32, float64, int32...)

name An optional name string for the layer. Should be unique in a model (do not reuse the same name twice). It will be autogenerated if it isn't provided.

trainable Whether the layer weights will be updated during training.

weights Initial weights for layer.