Skip to content

Instantly share code, notes, and snippets.

@TheOnlyArtz
Created February 7, 2020 15:53
Show Gist options
  • Save TheOnlyArtz/7f2278b891a4d5b36034c3ff7e19c2d6 to your computer and use it in GitHub Desktop.
Save TheOnlyArtz/7f2278b891a4d5b36034c3ff7e19c2d6 to your computer and use it in GitHub Desktop.
using Flux
using Flux: @epochs
using BSON: @save
using BSON: @load
using Random
# using Flux
print("Running!")
Random.seed!(1234);
model = Dense(2, 1)
loss(x, y) = Flux.mse(model(x), y)
# @load "mymodel.bson" weights
# Flux.loadparams!(model, weights)
ps = Flux.params(model)
data = []
gen1 = () -> return rand(1:55555)
for i in 1:9000
s = gen1()
a = gen1()
push!(data, ([s, a], s + a))
end
opt = ADAM()
epoch_count = 0
s = function()
global epoch_count
epoch_count = epoch_count + 1
if (epoch_count == 100)
x1 = gen1()
x2 = gen1()
y = x1 + x2
println(y)
@show(model([x1, x2]))
epoch_count = 0
end
end
@epochs 500 Flux.train!(loss, ps, data, opt, cb = () -> s())
# end
@save "mymodel.bson" model
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment