deepviz icon indicating copy to clipboard operation
deepviz copied to clipboard

Error in data.frame(...): arguments imply differing number of rows: 2, 0

Open hermandr opened this issue 6 years ago • 5 comments

I tried to reproduce the example in the readme. I encountered this error.

library(reprex)
library(deepviz)
library(tidyverse)
library(keras)

model <- keras_model_sequential() %>%
  layer_dense(10, input_shape = 4) %>%
  layer_dense(2, activation = "sigmoid")

model %>% plot_model()
#> Error in data.frame(id = 1:n, type = type, label = label, stringsAsFactors = FALSE): arguments imply differing number of rows: 2, 0

Created on 2018-11-14 by the reprex package (v0.2.1)

hermandr avatar Nov 14 '18 15:11 hermandr

I'm unable to reproduce this error. I get a different error, though:

 Error: Result 1 is not a length 1 atomic vector 

This is the same error as reported by #2

andrie avatar Jan 21 '19 18:01 andrie

Hello @andrie -- I saw the same results as @hermandr. The following code sits in a knitr script.

library(keras)
library(rlang)
devtools::install_github("andrie/deepviz")
library(deepviz)
library(magrittr)

model <- keras_model_sequential() %>% 
  layer_dense(units = 32, input_shape = c(784)) %>% 
  layer_activation('relu') %>% 
  layer_dense(units = 10) %>% 
  layer_activation('softmax')

model %>% plot_model()

My instance recognizes that deepviz is already properly installed and moves on. Then I get this error:

Error in data.frame(id = 1:n, type = type, label = label, stringsAsFactors = FALSE) : 
  arguments imply differing number of rows: 2, 0

Object model appears to be properly formed.

Model
__________________________________________________________________________________________________
Layer (type)                                Output Shape                           Param #        
==================================================================================================
dense_4 (Dense)                             (None, 32)                             25120          
__________________________________________________________________________________________________
activation_4 (Activation)                   (None, 32)                             0              
__________________________________________________________________________________________________
dense_5 (Dense)                             (None, 10)                             330            
__________________________________________________________________________________________________
activation_5 (Activation)                   (None, 10)                             0              
==================================================================================================
Total params: 25,450
Trainable params: 25,450
Non-trainable params: 0
__________________________________________________________________________________________________

roberthadow avatar Apr 07 '19 21:04 roberthadow

I tried your code example today, using a fresh install of keras and the underlying keras Python libraries. I could not reproduce.

My hunch is that there was an internal change in the way that keras represents model objects, and a recent version of deepviz accounts for this.

Please reinstall your keras python libraries, as well as the keras package and try again. If the error still persists, please provide your sessioninfo::session_info().

andrie avatar Apr 08 '19 16:04 andrie

Hello Andrie –

I don’t want you to spend you day debugging my stuff. Here is the story, though.

I updated Conda base. Then I tried to run my code, which gave no untoward indications. When I looked to see what model looked like, I got: <pointer: 0x0>

So I reran the the five lines that define the model and here’s what I got:

Error: lexical error: invalid char in json text.

                                       WARNING: The conda.compat modul

                     (right here) ------^

And the same error when I tried to execute in R: install_keras(version="default")

So I figured, try updating Conda again. I got the following warning: WARNING: The conda.compat module is deprecated blah blah (which I didn’t get the first time).

Clearly, my problem lies in conda somewhere, not in deepviz. I’ll play around with it.

Here is my session_info anyway.

> sessioninfo::session_info()
- Session info ---------------------------------------------------------------------------------
 setting  value                       
 version  R version 3.5.2 (2018-12-20)
 os       Windows >= 8 x64            
 system   x86_64, mingw32             
 ui       RStudio                     
 language (EN)                        
 collate  English_United States.1252  
 ctype    English_United States.1252  
 tz       America/New_York            
 date     2019-04-08                  
 
- Packages -------------------------------------------------------------------------------------
 package      * version    date       lib source                         
 assertthat     0.2.1      2019-03-21 [1] CRAN (R 3.5.3)                 
 backports      1.1.3      2018-12-14 [1] CRAN (R 3.5.2)                 
 base64enc      0.1-3      2015-07-28 [1] CRAN (R 3.5.0)                 
 brew           1.0-6      2011-04-13 [1] CRAN (R 3.5.0)                 
 callr          3.2.0      2019-03-15 [1] CRAN (R 3.5.3)                 
 cli            1.1.0      2019-03-19 [1] CRAN (R 3.5.3)                 
 colorspace     1.4-1      2019-03-18 [1] CRAN (R 3.5.3)                 
 crayon         1.3.4      2017-09-16 [1] CRAN (R 3.3.3)                 
 deepviz      * 0.0.1.9000 2019-04-07 [1] Github (andrie/deepviz@2a35de6)
 desc           1.2.0      2018-05-01 [1] CRAN (R 3.5.0)                 
 devtools       2.0.1      2018-10-26 [1] CRAN (R 3.5.2)                 
 DiagrammeR     1.0.0      2018-03-01 [1] CRAN (R 3.5.3)                 
 digest         0.6.18     2018-10-10 [1] CRAN (R 3.5.2)                 
 downloader     0.4        2015-07-09 [1] CRAN (R 3.5.3)                 
 dplyr          0.8.0.1    2019-02-15 [1] CRAN (R 3.5.3)                 
 farver         1.1.0      2018-11-20 [1] CRAN (R 3.5.3)                 
 fs             1.2.7      2019-03-19 [1] CRAN (R 3.5.3)                 
 generics       0.0.2      2018-11-29 [1] CRAN (R 3.5.2)                 
 ggforce        0.2.1      2019-03-12 [1] CRAN (R 3.5.3)                 
 ggplot2        3.1.1      2019-04-07 [1] CRAN (R 3.5.2)                 
 ggraph         1.0.2      2018-07-07 [1] CRAN (R 3.5.3)                 
 ggrepel        0.8.0      2018-05-09 [1] CRAN (R 3.5.3)                 
 glue           1.3.1      2019-03-12 [1] CRAN (R 3.5.3)                 
 gridExtra      2.3        2017-09-09 [1] CRAN (R 3.3.3)                 
 gtable         0.3.0      2019-03-25 [1] CRAN (R 3.5.3)                 
 hms            0.4.2      2018-03-10 [1] CRAN (R 3.3.3)                 
 htmltools      0.3.6      2017-04-28 [1] CRAN (R 3.5.0)                 
 htmlwidgets    1.3        2018-09-30 [1] CRAN (R 3.5.2)                 
 igraph         1.2.4      2019-02-13 [1] CRAN (R 3.5.3)                 
 influenceR     0.1.0      2015-09-03 [1] CRAN (R 3.5.3)                 
 jsonlite       1.6        2018-12-07 [1] CRAN (R 3.5.2)                 
 keras        * 2.2.4.1    2019-04-05 [1] CRAN (R 3.5.2)                 
 lattice        0.20-38    2018-11-04 [2] CRAN (R 3.5.2)                 
 lazyeval       0.2.2      2019-03-15 [1] CRAN (R 3.5.3)                 
 magrittr     * 1.5        2014-11-22 [1] CRAN (R 3.3.3)                 
 MASS           7.3-51.3   2019-03-31 [1] CRAN (R 3.5.3)                 
 Matrix         1.2-15     2018-11-01 [2] CRAN (R 3.5.2)                 
 memoise        1.1.0      2017-04-21 [1] CRAN (R 3.5.0)                 
 munsell        0.5.0      2018-06-12 [1] CRAN (R 3.5.0)                 
 pillar         1.3.1      2018-12-15 [1] CRAN (R 3.5.2)                 
 pkgbuild       1.0.3      2019-03-20 [1] CRAN (R 3.5.3)                 
 pkgconfig      2.0.2      2018-08-16 [1] CRAN (R 3.5.2)                 
 pkgload        1.0.2      2018-10-29 [1] CRAN (R 3.5.2)                 
 plyr           1.8.4      2016-06-08 [1] CRAN (R 3.5.0)                 
 polyclip       1.10-0     2019-03-14 [1] CRAN (R 3.5.3)                 
 prettyunits    1.0.2      2015-07-13 [1] CRAN (R 3.5.2)                 
 processx       3.3.0      2019-03-10 [1] CRAN (R 3.5.3)                 
 ps             1.3.0      2018-12-21 [1] CRAN (R 3.5.2)                 
 purrr          0.3.2      2019-03-15 [1] CRAN (R 3.5.3)                 
 R6             2.4.0      2019-02-14 [1] CRAN (R 3.5.3)                 
 RColorBrewer   1.1-2      2014-12-07 [1] CRAN (R 3.3.2)                 
 Rcpp           1.0.1      2019-03-17 [1] CRAN (R 3.5.3)                 
 readr          1.3.1      2018-12-21 [1] CRAN (R 3.5.2)                 
 remotes        2.0.2      2018-10-30 [1] CRAN (R 3.5.2)                 
 reticulate     1.11.1     2019-03-06 [1] CRAN (R 3.5.3)                 
 rgexf          0.15.3     2015-03-24 [1] CRAN (R 3.5.3)                 
 rlang        * 0.3.3      2019-03-29 [1] CRAN (R 3.5.3)                 
 Rook           1.1-1      2014-10-20 [1] CRAN (R 3.5.2)                 
 rprojroot      1.3-2      2018-01-03 [1] CRAN (R 3.3.3)                 
 rstudioapi     0.10       2019-03-19 [1] CRAN (R 3.5.3)                 
 scales         1.0.0      2018-08-09 [1] CRAN (R 3.5.2)                 
 sessioninfo    1.1.1      2018-11-05 [1] CRAN (R 3.5.2)                 
 stringi        1.4.3      2019-03-12 [1] CRAN (R 3.5.3)                 
 stringr        1.4.0      2019-02-10 [1] CRAN (R 3.5.3)                 
 tensorflow     1.13.1     2019-04-05 [1] CRAN (R 3.5.2)                 
 testthat       2.0.1      2018-10-13 [1] CRAN (R 3.5.3)                 
 tfruns         1.4        2018-08-25 [1] CRAN (R 3.5.1)                 
 tibble         2.1.1      2019-03-16 [1] CRAN (R 3.5.3)                 
 tidygraph      1.1.2      2019-02-18 [1] CRAN (R 3.5.3)                 
 tidyr          0.8.3      2019-03-01 [1] CRAN (R 3.5.3)                 
 tidyselect     0.2.5      2018-10-11 [1] CRAN (R 3.5.3)                 
 tweenr         1.0.1      2018-12-14 [1] CRAN (R 3.5.3)                 
 usethis        1.4.0      2018-08-14 [1] CRAN (R 3.5.2)                 
 viridis        0.5.1      2018-03-29 [1] CRAN (R 3.5.0)                 
 viridisLite    0.3.0      2018-02-01 [1] CRAN (R 3.3.3)                 
 visNetwork     2.0.6      2019-03-26 [1] CRAN (R 3.5.3)                 
 whisker        0.3-2      2013-04-28 [1] CRAN (R 3.5.0)                 
 withr          2.1.2      2018-03-15 [1] CRAN (R 3.5.0)                 
 XML            3.98-1.19  2019-03-06 [1] CRAN (R 3.5.2)                 
 yaml           2.2.0      2018-07-25 [1] CRAN (R 3.5.2)                 
 zeallot        0.1.0      2018-01-28 [1] CRAN (R 3.5.1)                 
 
[1] F:/repo/R-3.3.3/library
[2] C:/Program Files/R/R-3.5.2/library

roberthadow avatar Apr 08 '19 18:04 roberthadow

Looks like the problem is elsewhere: https://github.com/rstudio/keras/issues/733

roberthadow avatar Apr 08 '19 20:04 roberthadow