Hi, I am learning how to work with Keras and Python but I want to try using Julia too. One of the early tests I made was using Keras to make a regression to predict a number. Does anyone have suggestions on what I could try (or what I could read) to get better results with Flux?
Julia 1.6.1
Flux 0.12.3
Dataset from UCI Machine Learning Repository: Bike Sharing Dataset Data Set
The Keras example…
model = Sequential()
model.add(Dense(13, input_dim=13, activation='relu'))
model.add(Dense(1, activation='linear'))
model.compile(loss='mean_squared_error', optimizer = 'adam', metrics = ['mse', 'mae'])
estimator= model.fit(x, y, epochs=500, verbose=1)
print("mse: ", estimator.history['mse'][-1], " mae: ", estimator.history['mae'][-1])
Which gives me results like mse: 0.0518 - mae: 0.1762
When I try with Flux…
model = Chain(
Dense(13,13, relu),
Dense(13,1, identity)
)
loss(x, y) = Flux.Losses.mse(model(x), y)
theParameters = Flux.params(model)
optimiser = ADAM()
epochs = 500
@time for i = 1:epochs # using for loop instead of epochs macro to avoid log spam
Flux.train!(loss, theParameters, [(training,y)], optimiser)
end
print("mse: ", loss_mse[epochs]," mae: ",loss_mae[epochs])
I get results like
mse: 6.883073257723706e6 mae: 2129.58720440448
I prepare the data for Flux as…
myData = CSV.read("Bike-Sharing-Dataset/day.csv", DataFrame; header = true)
x = myData[:,3:15]
y = myData[:,16]
xmat = convert(Matrix, x)
training = transpose(xmat)