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
using Gtk, Plots, Cairo | |
using DataStructures | |
function replaceBiggest!(a,b) | |
selinds = abs.(a) .< abs.(b) | |
a[ selinds ] .= b[ selinds ] | |
end | |
mutable struct ClickablePlot |
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
using DiffEqFlux, OrdinaryDiffEq, Flux, MLDataUtils, NNlib | |
using Flux: logitcrossentropy | |
using MLDatasets: MNIST | |
function loadmnist(batchsize = bs) | |
# Use MLDataUtils LabelEnc for natural onehot conversion | |
onehot(labels_raw) = convertlabel(LabelEnc.OneOfK, labels_raw, LabelEnc.NativeLabels(collect(0:9))) | |
# Load MNIST | |
imgs, labels_raw = MNIST.traindata(); | |
# Process images into (H,W,C,BS) batches |
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
kasemiir <- as.data.frame(read.csv2("/mydata2.csv")) | |
#i batches(BatchID), j variables and k time(Time) | |
batch_part <- split(kasemiir, f=kasemiir$BatchID) | |
#now we have a list of dataframes split over batchid | |
#z[[2]] #is batch2 etc... | |
#make sure each subdf is ordered by time and convert to matrix | |
for( subdf in batch_part){ | |
subdf <- data.matrix( subdf[order("Time")] ) | |
} |
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
import DSP: conv | |
using LinearAlgebra | |
function boundaries( ::Val{:zeros}, x::Vector, half_width::Int ) | |
return (padded = true, z = vcat( zeros(half_width), x, zeros(half_width) ) ) | |
end | |
function boundaries( ::Val{:repeating}, x::Vector, half_width::Int ) | |
return (padded = true, z = vcat( repeat( [ first(x) ], half_width), x, repeat( [ last(x) ], half_width) ) ) | |
end | |
function boundaries( ::Val{:mirroring}, x::Vector, half_width::Int ) |
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
using GeometryBasics | |
x(a::Point{2, T}) where { T <: Number } = first(a) | |
y(a::Point{2, T}) where { T <: Number } = last(a) | |
#Ewy | |
Matrix(z::Vector{Point{2, T}}) where { T <: Number } = hcat( z .|> x, z .|> y ) | |
to_points(z) = [ Point(z[:,r][:]...) for r in 1:size(z,2)] | |
function orientation(p::Point{2, T}, q::Point{2, T}, r::Point{2, T})::Int where {T <: Number } | |
val = ( y(q) - y(p) ) * ( x(r) - x(q) ) - ( x(q) - x(p) ) * ( y(r) - y(q) ) |
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
using GeometryBasics | |
x(a::AbstractVector) = first(a) | |
y(a::AbstractVector) = last(a) | |
x(a::AbstractMatrix) = a[ :, 1 ] | |
y(a::AbstractMatrix) = a[ :, 2 ] | |
function orientation(p::AbstractVector, q::AbstractVector, r::AbstractVector)::Int | |
val = ( y(q) - y(p) ) * ( x(r) - x(q) ) - ( x(q) - x(p) ) * ( y(r) - y(q) ) | |
return (val ≈ 0) ? 0 : ( (val > 0) ? 1 : 2 ) |
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
# uses Flux.v11 | |
using Plots, Flux | |
function update!(opt, x, x̄) | |
x[:] .-= apply!(opt, x, x̄)[:] | |
end | |
function update!(opt, xs::Flux.Params, gs) | |
for x in xs | |
(gs[x] === nothing) && continue |
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
function NNLS_CD(X, Y; ϵ = 1e-9, max_iters = 300) | |
rows,vars = size(X) | |
XTX,XTY = transpose(X) * X, transpose(X) * Y | |
x = zeros(vars) | |
μ = -XTY | |
Hxf = similar(XTY) | |
@inbounds for iter in 1:max_iters | |
Hxf = XTX * x - XTY | |
all(>=(-ϵ), Hxf) && break | |
for v in 1:vars |
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
rmsrosa | |
— | |
10/27/2021 | |
I essentially followed the instructions here, which is a pretty recent post: https://www.linkedin.com/pulse/running-julia-my-android-phone-paresh-mathur, except I didn't install Ubuntu, but Fedora, for which I used https://github.com/nmilosev/termux-fedora. | |
1. Install Termux on your Android phone from the F-Droid (don't use the one from the App Store, it is outdated and not maintained). See https://termux.com/ | |
2. Update Termux just in case: pkg update && pkg upgrade | |
3. Install a linux distro. I used Fedora, but can be anything: |