Last active
January 13, 2020 15:22
-
-
Save JulienPascal/24093fce229860adc19daf5a034036a5 to your computer and use it in GitHub Desktop.
CNN with Julia
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
# Model definition | |
# See: https://github.com/FluxML/model-zoo/blob/master/vision/mnist/conv.jl | |
model = Chain( | |
# First convolution, operating upon a 28x28 image | |
Conv((3, 3), 1=>16, pad=(1,1), relu), | |
MaxPool((2,2)), #maxpooling | |
# Second convolution, operating upon a 14x14 image | |
Conv((3, 3), 16=>32, pad=(1,1), relu), | |
MaxPool((2,2)), #maxpooling | |
# Third convolution, operating upon a 7x7 image | |
Conv((3, 3), 32=>32,pad=(1,1), relu), | |
MaxPool((2,2)), | |
# Reshape 3d tensor into a 2d one, at this point it should be (3, 3, 32, N) | |
# which is where we get the 288 in the `Dense` layer below: | |
x -> reshape(x, :, size(x, 4)), | |
Dense(288, 10), | |
# Softmax to get probabilities | |
softmax, | |
) | |
# Load on gpu (if available) | |
model = gpu(model); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment