This file contains hidden or 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 hidden or 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 hidden or 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
| 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 |
This file contains hidden or 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 hidden or 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 hidden or 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); |
This file contains hidden or 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 hidden or 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 | |
| vcat([hcat([CIFAR100.convert2image(x_train[:, :, :, i + 20*j]) for i in 1:20]...) for j in 0:9]...) |
This file contains hidden or 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.convert2image(x_train[:, :, :, 1]) |
This file contains hidden or 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
| 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} |