How to get a output of a hidden layer of a single-layer LSTM
How can get the hidden layer outputs in a simple one-layer lstm?
cat("Building Model\n")
model - keras_model_sequential() %%
layer_lstm(units = 64, dropout = 0.2, input_shape = c(seqlength, length(chars))) %%
layer_dense(units = length(chars), activation = "softmax") %%
compile(loss = 'categorical_crossentropy',
optimizer = optimizer_sgd(lr = 0.001,
decay = 1e-6,
momentum = 0.9,
nesterov = T),
metrics = c('accuracy'))
summary(model)
cat("Training \n")
history - model %%
fit(train,
trainLabels,
epochs = 6,
batch_size = 16,
validation_split = 0.2)
I found this guid but I don't know how to fit it to this simple model and what is data.
model - ... # create the original model
layer_name - 'my_layer' intermediate_layer_model - keras_model(inputs =
model$input,outputs = get_layer(model, layer_name)$output)
intermediate_output - predict(intermediate_layer_model, data)
Can anybody give a sample of this?
Topic lstm keras rstudio deep-learning r
Category Data Science