renamed files, lesson 10/11

This commit is contained in:
elvis
2023-11-15 11:23:16 +01:00
parent 8d7c769823
commit 9e7f427faa
188 changed files with 321 additions and 7 deletions

31
11-08/interactiverec.jl Normal file
View File

@ -0,0 +1,31 @@
using LinearAlgebra, Plots, Statistics
include("../11-03/readyalefaces_to_tensor.jl")
function interactiverec(F, iterstop::Union{Nothing, Integer}=nothing)
# given a 243x320 image F, displays it as sum of components
stdsize = (243, 320)
(X, _) = readyalefaces_to_tensor()
X = reshape(X, (prod(stdsize), Integer(prod(size(X)) / prod(stdsize))))
avg = mean(X, dims=2)
Xs = X .- avg
(U,S,V) = svd(X)
h = Plots.heatmap(reshape(avg, stdsize), yflip=true)
display(h)
if iterstop == nothing
upto = size(U, 2)
else
upto = min(size(U, 2), iterstop)
end
# no fancy slider, not enough time
for d 0:upto
h = heatmap(reshape(avg .+ U[:, 1:d] * U[:, 1:d]' * F, stdsize), yflip=true)
IJulia.clear_output(true)
display(h)
end
end