Skip to content

Instantly share code, notes, and snippets.

View alstat's full-sized avatar

Al Asaad alstat

View GitHub Profile
library(keras)
# Define the constants
CONST_N <- 2000
CONST_EPOCHS <- 30
CONST_PIXEL_MAX <- 255
from numpy import arange, product, vstack, zeros
from keras.models import Sequential
from keras.layers import Activation, Dense, Dropout
from keras.datasets import cifar100
from keras.utils.np_utils import to_categorical
from matplotlib.pylab import axis, imshow, savefig, show, subplots
# Define the constants
CONST_N = 2000
CONST_EPOCHS = 30
install.packages("keras")
using Images
using MLDatasets
using Flux: ADAM,
argmax,
Chain,
crossentropy,
Dense,
params,
relu,
softmax,
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);
using Flux: ADAM,
argmax,
Chain,
Dense,
params,
relu,
softmax
m = Chain(
Dense(32^2 * 3, 32 * 10, relu),
using Images
vcat([hcat([CIFAR100.convert2image(x_train[:, :, :, i + 20*j]) for i in 1:20]...) for j in 0:9]...)
CIFAR100.convert2image(x_train[:, :, :, 1])
size(x_train) # (32, 32, 3, 50000)
size(y_train_coarse) # (50000,)
size(y_train_fine) # (50000,)
typeof(x_train)  # Array{FixedPointNumbers.Normed{UInt8,8},4}
typeof(y_train_coarse) # Array{Int64,1}
typeof(y_train_fine) # Array{Int64,1}
using MLDatasets
x_train, y_train_coarse, y_train_fine = CIFAR100.traindata();