Skip to content

Instantly share code, notes, and snippets.

@alstat
Created March 10, 2018 09:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alstat/dd05a85300c861322ff777715053e466 to your computer and use it in GitHub Desktop.
Save alstat/dd05a85300c861322ff777715053e466 to your computer and use it in GitHub Desktop.
items <- list(x_train, y_train, x_test, y_test)
dim_formatter <- function (x) {
if (length(dim(x)) > 2)
paste("(", dim(x)[1], ", ", dim(x)[2], " , ", dim(x)[3], " , ", dim(x)[4], ")", sep = "")
else
paste("(", dim(x)[1], ", ", dim(x)[2], ")", sep = "")
}
# training set
unlist(lapply(items[1:2], function(x) class(x))) # [1] "array" "matrix"
unlist(lapply(items[1:2], dim_formatter)) # [1] "(50000, 32 , 32 , 3)" "(50000, 1)"
# testing set
unlist(lapply(items[3:4], function(x) class(x))) # [1] "array" "matrix"
unlist(lapply(items[3:4], dim_formatter)) # [1] "(10000, 32 , 32 , 3)" "(10000, 1)"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment