Skip to content

Instantly share code, notes, and snippets.

View alstat's full-sized avatar

Al Asaad alstat

View GitHub Profile
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)
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)]
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
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
(x_train, y_train), (x_test, y_test) = cifar100.load_data(label_mode = "fine")
library(keras)
# Define the constants
CONST_N <- 2000
CONST_EPOCHS <- 30
CONST_PIXEL_MAX <- 255
install.packages("keras")
using Images
using MLDatasets
using Flux: ADAM,
argmax,
Chain,
crossentropy,
Dense,
params,
relu,
softmax,
using Flux: ADAM,
argmax,
Chain,
Dense,
params,
relu,
softmax
m = Chain(
Dense(32^2 * 3, 32 * 10, relu),
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);