Deep Learning

심층신경망학습

[Flux] MNIST example update

수정부문: 기존accuracy(x,y) = mean(onecold(m(x) .== onecold(y))loss(x,y) = crossentropy(m(x),y) 변경# ϵ : loss함수가 NaN이 되는것을 방지ϵ = 1.0f-32loss(x,y) = crossentropy(m(x) .+ ϵ,y) # onecold가 GPU에서는 에러 발생 하기 때무에 아래로 대체참조 : https://github.com/FluxML/Flux.jl/issues/556 compare(y::OneHotMatrix, y′) = maximum(y′, dims = 1) .== maximum(y .* y′, dims = 1)accuracy(x, y::OneHotMatrix) = mean(compare(y, m(x))) mnist.jl

[Flux] MNIST example update Read More »

[Flux] RNN example – char_rnn_gpu_minibatch

https://github.com/FluxML/model-zoo/blob/master/text/char-rnn/char-rnn.jl 의 error fix 및 수정 확장본 환경 : Julia v1.3.1, Flux v0.10.1 char-rnn의 이해를 위한 jupyer notebook (html) –> click here github : https://github.com/mrchaos/model-zoo/blob/master/text/char-rnn/char_rnn_gpu_minibatch.jl char_rnn_gpu_minibatch.jl

[Flux] RNN example – char_rnn_gpu_minibatch Read More »

[Flux] model-zoo fix conv.jl

mnist에 cnn을 적용한 예제가 conv.jl인데 Flux v0.10.1에서 많은 문제가 발생하여 수정하고 몇가지 기능을 추가 했다. 원래 conv.jl : click here! 기존의 소스를 수정하여 새로 추가한 소스 : click here! conv_gpu_minibatch.jl cmd_parser.jl 기존 conv.jl 의 loss function이 아래와 같이 정의 되어 있는데 x_aug = x .+ 0.1f0*gpu(randn(eltype(x), size(x))) 에서 에러 발생 하여 loss를 아래 와 같이

[Flux] model-zoo fix conv.jl Read More »

[Flux] model-zoo tutorial with Zygote

Model-zoo 60분 튜토리얼 : https://github.com/FluxML/model-zoo/blob/master/tutorials/60-minute-blitz.jl 위의 모델은 Flux가 Tracker를 채택하고 있을 때 예제로서 개념은 좋으나 Flux 0.10.x 부터는 Zygote 기반이므로 재대로 동작 하지 않는다 위의 예제는 Flux v0.10.1 버전이며 Zygote 기반으로 수정한 버전이다. Jupyter note (html 버전) –> Click here

[Flux] model-zoo tutorial with Zygote Read More »

[Flux] cifar10 upgraded example

이전 cifar10 example에서 모델을 저장하고 읽어오는 부분을 추가 하고 , 외부 파라미터를 입력 받아 반영 하는 구조로 변경 하였다. training한 model을 저장하고 읽기 기능을 추가 하여 이어서 training을 할 수 있게 했다 epoch, batch size, 저장된 model 파일 로딩 여부,로그를 화면 또는 파일로 저장, gpu device , gpu device 를 선택 할 수 있게 했다.

[Flux] cifar10 upgraded example Read More »

[Flux] cifar10 example – gpu,minibatch, fix loss NaN

model-zoo : https://github.com/FluxML/model-zoo/blob/master/vision/cifar10/cifar10.jl 소스를 수정함 수정된 소스 : https://github.com/mrchaos/model-zoo/blob/master/vision/cifar10/cifar10_gpu_minibatch.jl 이 글을 보기전에 먼저 아래 글을 참조 하는 것이 좋다. 그리고 cifar10.jl을 이해하는데 도움이 될만한 jupyter notebook(html) ==> 여기 cifar10_gpu_minibatch.jl (몇가지 설명이 더 추가 되어 있음) 위의 첨부파일에 소스에서 “CUDAnative.device!(3)” 을 주석 처리 하면 첫번째 GPU에서 실행된다

[Flux] cifar10 example – gpu,minibatch, fix loss NaN Read More »

[Flux] mnist example with gpu, mini-batch, fix loss NaN

소스 URL : https://github.com/mrchaos/model-zoo/blob/master/vision/mnist/mlp_gpu_minibatch.jl model zoo의 mnist예제 중 mlp.jl 소스에 몇가지 이슈가 있어 수정하고 미니배치를 적용 하였다. Julia 1.3.1, Flux 0.10.1 을 사용 하였다. 가장 큰 이슈는 loss function에서 NaN이 발생하여 train이 제대로 되지 않는 문제를 수정 했다. loss가 아래와 같이 정의 되는 경우 mini-batch를 적용하면 계산 되는 batch 데이터가 적기 때문에 자주 NaN이 발생한다.

[Flux] mnist example with gpu, mini-batch, fix loss NaN Read More »