0
$\begingroup$

I have timeseries machine sensor data and I would like to predict when the machine fails using the sensor data. There are 4 Failure states and 1 Normal state, total of 5 classes.

I am trying to solve for multiclass classification on timeseries data using an LSTM model.

I came across TimeDistributed Layer when searching for different LSTM architectures. However it was being used for seq2seq predictions.

I was wondering if I can make use of TimeDistributed Layer for my problem and if yes, then how should I add it to my basic LSTM model.

def create_lstm_model(MaxTimeslice, H, LR, num_classes, dropout_rate=0.1, l2_reg=0.0001):

    ip = Input(shape=(MaxTimeslice, H))

    x = LSTM(128, return_sequences=True, dropout=dropout_rate, kernel_regularizer=l2(l2_reg))(ip)
    x = LSTM(64, return_sequences=True, dropout=dropout_rate, kernel_regularizer=l2(l2_reg))(ip)
    
    x = LSTM(32, dropout=dropout_rate, kernel_regularizer=l2(l2_reg))(x)

    x = Dense(units=64, activation='relu')(x)
    x= Dropout(rate=dropout_rate)(x)
    x = Dense(units=32, activation='relu')(x)
    x= Dropout(rate=dropout_rate)(x)
    multiclass_output = Dense(units=num_classes, activation='softmax')(x)

    model = Model(inputs=ip, outputs=multiclass_output)

    model.compile(loss="categorical_crossentropy",
                  metrics=["accuracy"],
                  optimizer=RMSprop(learning_rate=LR))

    return model

Would it make sense to add the TimeDistributed Layer before the LSTM layer, or after?

$\endgroup$

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.