deepviz
deepviz copied to clipboard
Weird error with Ubuntu 18.04 install
I'm getting a strange error when installing on Ubuntu 18.04. First, I installed R 3.5 following these instructions. Then I installed r-cran-devtools
(sudo apt install r-cran-devtools
). Then I installed deepviz
with devtools::install_github("andrie/deepviz")
. Finally, I tried to run an example:
library(deepviz)
library(magrittr)
require(keras)
model <- keras_model_sequential() %>%
layer_dense(10, input_shape = 4) %>%
layer_dense(2, activation = "sigmoid")
model %>% plot_model()
but it gave this error:
Error in data.frame(id = 1:n, type = type, label = label, stringsAsFactors = FALSE) :
arguments imply differing number of rows: 2, 0
The traceback()
looks like this:
17: stop(gettextf("arguments imply differing number of rows: %s",
paste(unique(nrows), collapse = ", ")), domain = NA)
16: data.frame(id = 1:n, type = type, label = label, stringsAsFactors = FALSE)
15: dots_values(...)
14: flatten_bindable(dots_values(...))
13: dplyr::bind_cols(data.frame(id = 1:n, type = type, label = label,
stringsAsFactors = FALSE), extras)
12: create_node_df(n = length(model_layers), name = l_name, type = l_type,
label = glue::glue("{l_name}\n{l_type}\n{l_activation}"),
shape = "rectangle", activation = l_activation)
11: model_nodes(model)
10: plot_model.keras.engine.training.Model(.)
9: plot_model(.)
8: function_list[[k]](value)
7: withVisible(function_list[[k]](value))
6: freduce(value, `_function_list`)
5: `_fseq`(`_lhs`)
4: eval(quote(`_fseq`(`_lhs`)), env, env)
3: eval(quote(`_fseq`(`_lhs`)), env, env)
2: withVisible(eval(quote(`_fseq`(`_lhs`)), env, env))
1: model %>% plot_model()
So it appears to be happening on this line.
I think this might actually have to do with the recent release of the CRAN version of keras: https://github.com/rstudio/keras/releases
I think something changed with the way layers are accessed. This line in model_nodes
no longer works:
model_layers <- x$get_config()$layers
Ok that was a saga to figure out, but it turns out the newest version of keras
works like this: layers from a sequential model can be found from model$get_config()
, but from the functional model, they are still model_layers <- model$get_config()$layers
.