Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error in pop_layer() for non sequential models #400

Closed
MaximilianPi opened this issue May 14, 2018 · 2 comments
Closed

Error in pop_layer() for non sequential models #400

MaximilianPi opened this issue May 14, 2018 · 2 comments

Comments

@MaximilianPi
Copy link

MaximilianPi commented May 14, 2018

I'm not sure if this is intended but pop_layer() does not work for non sequential models.
Here a simple example:

x = matrix(runif(200), ncol = 5, nrow = 40)
y = x %*% matrix(1:5, ncol = 1) +3
input = layer_input(shape = 5L)
output = input %>% 
  layer_dense(input_shape = 5L, activation = "relu",units = 20) %>%
  layer_dense(units = 1, activation = "linear") 


model = keras_model(inputs = input, outputs = output)
model %>% 
  compile(
    loss = "poisson",
    optimizer = "rmsprop",
    metrics = "mean_squared_error"
  )
model %>% 
  fit(
    x = x,
    y = y,
    epochs = 5
  )
model %>% pop_layer()
Error: Python object has no '__getitem__' method
sessionInfo()
R version 3.5.0 (2018-04-23)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows >= 8 x64 (build 9200)
[1]   tensorflow_1.5.0.9001    keras_2.1.6.9001 
@jjallaire
Copy link
Member

@kevinushey The source code for pop_layer() is this:

pop_layer <- function(object) {
  object$pop()
}

This looks suspiciously like something caused by rstudio/reticulate#255

@jjallaire
Copy link
Member

I didn't realize you were using the Function API. pop() is actually only supported for Sequential models: keras-team/keras#5096

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants