This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
f, a = subplots(10, 20) | |
for i in arange(10): | |
for j in arange(20): | |
a[i, j].imshow(x_train[j + 20 * i]) | |
a[i, j].axis("off") | |
a[i, j].set_adjustable('box-forced') | |
f.savefig("img1.png", bbox_inches='tight', pad_inches = 0) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
items = [x_train, y_train, x_test, y_test] | |
# training set | |
[type(item) for item in items[:2]] # [<type 'numpy.ndarray'>, <type 'numpy.ndarray'>] | |
[item.shape for item in items[:2]] # [(50000, 32, 32, 3), (50000, 1)] | |
# testing set | |
[type(item) for item in items[2:]] # [<type 'numpy.ndarray'>, <type 'numpy.ndarray'>] | |
[item.shape for item in items[2:]] # [(10000, 32, 32, 3), (10000, 1)] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cifar100 <- dataset_cifar100(label_mode = "fine") | |
x_train <- cifar100$train$x; y_train <- cifar100$train$y | |
x_test <- cifar100$test$x; y_test <- cifar100$test$y |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(x_train, y_train), (x_test, y_test) = cifar100.load_data(label_mode = "fine") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(keras) | |
# Define the constants | |
CONST_N <- 2000 | |
CONST_EPOCHS <- 30 | |
CONST_PIXEL_MAX <- 255 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
install.packages("keras") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Images | |
using MLDatasets | |
using Flux: ADAM, | |
argmax, | |
Chain, | |
crossentropy, | |
Dense, | |
params, | |
relu, | |
softmax, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Flux: ADAM, | |
argmax, | |
Chain, | |
Dense, | |
params, | |
relu, | |
softmax | |
m = Chain( | |
Dense(32^2 * 3, 32 * 10, relu), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Flux: onehotbatch | |
x_vec = [float.(reshape(x_train[:, :, :, i], :)) for i in 1:1000]; | |
X = hcat(x_vec...); | |
Y = onehotbatch(y_train_fine[1:1000], 0:99); |