Skip to content

Instantly share code, notes, and snippets.

@Slater-Victoroff
Created February 11, 2014 06:13
Show Gist options
  • Save Slater-Victoroff/8930007 to your computer and use it in GitHub Desktop.
Save Slater-Victoroff/8930007 to your computer and use it in GitHub Desktop.
Julia Neural Net
type NeuralNet
weight_matrices::Array{Array{FloatingPoint}}
NeuralNet(layer_sizes::Array{Int64}) = new([
rand(layer_sizes[i], layer_sizes[i+1]) for i in [1:length(layer_sizes)-1]
])
end
function predict(input_vector::Array{Float64}, net::NeuralNet)
unshift!(net.weight_matrices, input_vector)
return reduce(*, net.weight_matrices)
end
test = NeuralNet([1, 400, 500, 2])
result = predict([0.5], test)
println(result)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment