Skip to content

Instantly share code, notes, and snippets.

@George3d6
Last active August 14, 2018 17:31
Show Gist options
  • Save George3d6/63553c05819db8db4f100b2494cb0f68 to your computer and use it in GitHub Desktop.
Save George3d6/63553c05819db8db4f100b2494cb0f68 to your computer and use it in GitHub Desktop.
Pkg.add("Knet")
Pkg.add("Plots")
Pkg.add("GR")
function julia(x, y, width, height, c)
z = ((y/width)*2.7 - 1.3) + ((x/height)*4.5 - 2.5)im
for i = 1:254
z = z^2 + c
if abs(z) >= 4
return Float32(i)
end
end
return Float32(255)
end
julia_set(height, width, c) = [julia(x, y, width, height, c) for x = 1:height, y = 1:width]
function get_training_data(n,size)
data = []
for i=1:n
c = 1.2e^( (rand()/10 + (n/14)*π)*im)
push!(data, julia_set(size, size, c))
end
cat(4, map(x -> cat(3,x),data)...)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment