I have the following code, copied and slightly modified from GitHub - r3tex/LossSurface: Efficient Neural Network Loss Landscape Generation. Here is the code:
sing Flux
#using CuArrays
batchsize = 64
dat_x = Flux.Data.FashionMNIST.images(:train)
dat_x = [reshape(Float32.(x), 28, 28, 1, 1) for x in dat_x]
dat_x = gpu.([reduce((x, y)->cat(x, y, dims=4), batch)
for batch in Iterators.partition(dat_x, batchsize)])
dat_y = Flux.Data.FashionMNIST.labels(:train)
dat_y = gpu.([Flux.onehotbatch(batch, 0:9)
for batch in Iterators.partition(dat_y, batchsize)])
dat = zip(dat_x, dat_y);
#-------------------------------------------------------
function large_vgg()
vgg = gpu(Chain(
Conv((3,3), 1 =>64, relu, pad=(1,1)), BatchNorm(64),
Conv((3,3), 64 =>64, relu, pad=(1,1)), BatchNorm(64),
# Change maxpool function signature (upgraded Flux)
MaxPool((2,2)),
Conv((3,3), 64 =>128, relu, pad=(1,1)), BatchNorm(128),
Conv((3,3), 128=>128, relu, pad=(1,1)), BatchNorm(128),
MaxPool((2,2)),
Conv((3,3), 128=>256, relu, pad=(1,1)), BatchNorm(256),
Conv((3,3), 256=>256, relu, pad=(1,1)), BatchNorm(256),
Conv((3,3), 256=>256, relu, pad=(1,1)), BatchNorm(256),
MaxPool((2,2)),
Conv((3,3), 256=>512, relu, pad=(1,1)), BatchNorm(512),
Conv((3,3), 512=>512, relu, pad=(1,1)), BatchNorm(512),
Conv((3,3), 512=>512, relu, pad=(1,1)), BatchNorm(512),
MaxPool((2,2)), x -> reshape(x, :, size(x,4)),
Dense(512, 4096, relu),
Dense(4096, 4096, relu), Dropout(0.5),
Dense(4096, 10),
softmax))
loss(x, y) = Flux.crossentropy(vgg(x), y)
Flux.train!(loss, params(vgg), dat, ADAM())
end
#-------------------------------------------------
function small_vgg()
vgg = gpu(Chain(
Conv((3,3), 1 =>64, relu, pad=(1,1)), BatchNorm(64),
Dense(64, 256, relu),
Dense(256, 256, relu), Dropout(0.5),
Dense(256, 10),
softmax))
loss(x, y) = Flux.crossentropy(vgg(x), y)
Flux.train!(loss, params(vgg), dat, ADAM())
end
######################################
which transferred from a Julia Notebook to Atom. Notice the original VGG networkm, packaged into a function named large_vgg() and a smaller network I wanted to run to save time packaged into the function small_vgg().
The larger network runs fine, in the sense that the code prints no output and does not stop, even after several minutes. The smaller code produces an error, which is: (the error dump is long, and I am having trouble cutting and pasting. What is the best way to select the full error message to transfer into this message box?) I only show the first few lines in this image:
I welcome any ideas because I am stuck. Thanks.