Error in keras trying to build an autoencoder

Hi,
I have recently installed keras/tensorflow on my computer and I am trying to build a basic autoencoder in R studio. No matter how many hidden layers I define, I keep receiving this error:

Error in py_call_impl(callable, dots$args, dots$keywords) : ValueError: No data provided for "bottleneck_input". Need data for each key in: ['bottleneck_input']

This is my code:

model1 <- keras_model_sequential()
model1 %>%
layer_dense(units = 3, activation = "tanh", name = "bottleneck", input_shape = ncol(traindata)) %>%
layer_dense(units = ncol(traindata))

model1 %>% compile(
loss = "mean_squared_error",
optimizer = "adam"
)

model1 %>% fit(
x = traindata,
y = traindata,
epochs = 10,
validation_split = 0.2
)

My train data dimension is 617 * 7 and I want to use autoencoder to reduce its dimension to 617 * 3 by using the output from the middle layer (bottleneck).
Any suggestions would be appreciated.

You are almost there. There are few things you need to do and so on. Here is an example on how autoencoder model looks like.

input_layer <- 
  layer_input(shape = c(3)) 

encoder <- 
  input_layer %>% 
  layer_dense(units = 2,  activation = "tanh") # 2 dimensions for the output layer

decoder <- 
  encoder %>% 
  layer_dense(units = 3) # 3 dimensions for the original 3 variables

model <- keras_model(inputs = input_layer, outputs = decoder)

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.