Skip to content

Commit 0eb7496

Browse files
committed
Lecture 10: Bugfix
1 parent 3c87993 commit 0eb7496

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

docs/src/lecture_10/nn.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -545,3 +545,29 @@ println("Test accuracy = " * string(accuracy(X_test, y_test))) # hide
545545
The externally trained model has an accuracy of more than 98% (it has the same architecture as the one defined above, but it was trained for 50 epochs.). Even though there are perfect models (with accuracy 100%) on MNIST, we are happy with this result. We will perform further analysis of the network in the exercises.
546546

547547

548+
549+
550+
```@setup nn
551+
using Plots
552+
553+
plot_image(x::AbstractArray{T, 2}) where T = plot(Gray.(1 .-x'), axis=false, ticks=false)
554+
555+
function plot_image(x::AbstractArray{T, 3}) where T
556+
size(x,3) == 1 || error("Image is not grayscale.")
557+
plot_image(x[:,:,1])
558+
end
559+
560+
ii = [1;2;54]
561+
562+
p1 = plot_image(X_train[:,:,:,ii[1]])
563+
p2 = plot_image(X_train[:,:,:,ii[2]])
564+
p3 = plot_image(X_train[:,:,:,ii[3]])
565+
566+
plot(p1, p2, p3; layout=(1,3), size=(900,300))
567+
568+
savefig("nn_intro.svg")
569+
570+
m_val = m(X_train[:,:,:,ii])
571+
p = maximum(m_val, dims=1)
572+
y_hat = onecold(m_val, 0:9)
573+
```

0 commit comments

Comments
 (0)