I am following this tutorial - How to build your own image recognition app with R! [Part 1] | R-bloggers
But have come across an error.
model_function <- function(learning_rate = 0.001,
dropoutrate=0.2, n_dense=1024){
k_clear_session()
model <- keras_model_sequential() %>%
mod_base %>%
layer_global_average_pooling_2d() %>%
layer_dense(units = n_dense) %>%
layer_activation("relu") %>%
layer_dropout(dropoutrate) %>%
layer_dense(units=output_n, activation="softmax")
model %>% compile(
loss = "categorical_crossentropy",
optimizer = optimizer_adam(lr = learning_rate),
metrics = "accuracy"
)
return(model)
}
model <- model_function()
The last line of this code gets the following error -
Error in py_call_impl(callable, call_args$unnamed, call_args$named) :
ValueError: Inputs to a layer should be tensors. Got '<Sequential name=sequential, built=False>' (of type <class 'keras.src.models.sequential.Sequential'>) as input for layer 'xception'.
Run `reticulate::py_last_error()` for details.
Does anyone know how I can fix this? Or have any recommendations on a different tutorial to follow?