While studying neural nets I came across 2 lines of code whose syntax baffle me.
I looked at the docs, but I still don’t get the 2 lines of code discussed below.
Each line is prefaced by code context.
-----------FIRST LINE-----------------------------
i = 5003 # simple
display(images[i]) # simple
#=
Here is the first line. I already know that this line outputs
a label value, largest Float64 in images data, and the prediction value associated with the largest Float64.
labels[i] are labels for data fed to neural network(NN);
images[i] are the data fed to the NN;
preprocess turns image data into Float64s;
model is the NN;
findmax returns the largest Float64.
What I don’t get is how the logic of this line works for the “.- (0, 1)” part; what is it doing and how?
=#
labels[i], findmax(model(preprocess(images[i]))) .- (0, 1)
-----------SECOND LINE-----------------------------
#= findmax, model, preprocess and images have already been defined above.
The following function definition returns largest Float64 and an index.
What I don’t get in this function definition is what the “[2]-1” part does. What is the logic behind it and how does it work?
=#
prediction(i) = findmax(model(preprocess(images[i])))[2]-1
Thank you in advance for helping me understand Julia syntax better.