mxnet
mxnet copied to clipboard
error with simple linear regression?
I wrote this simple code to fit simple linear regression:
###########################################
#############LINEAR REGRESSION#############
###########################################
library(mxnet)
library(magrittr)
x <- seq(1:1000)
y <- 3*x + rnorm(1000, 0, 200)
plot(x,y)
simple_nnet <- mx.symbol.Variable('data') %>%
mx.symbol.FullyConnected(num_hidden = 1) %>%
mx.symbol.LinearRegressionOutput()
mx.set.seed(1)
model_espiral <- mx.model.FeedForward.create(simple_nnet,
X = x,
y = y,
array.layout= "rowmajor",
eval.metric = mx.metric.rmse,
optimizer = "sgd",
learning.rate = 0.001,
momentum = 0.9,
num.round = 1000,
initializer = mx.init.Xavier(),
ctx = mx.cpu())
and the output :
[1] Train-rmse=287336592309880352
[2] Train-rmse=Inf
[3] Train-rmse=NaN
[4] Train-rmse=NaN
[5] Train-rmse=NaN
[6] Train-rmse=NaN
[7] Train-rmse=NaN
[8] Train-rmse=NaN
[9] Train-rmse=NaN
[10] Train-rmse=NaN
[11] Train-rmse=NaN
[12] Train-rmse=NaN
[13] Train-rmse=NaN
[14] Train-rmse=NaN
[15] Train-rmse=NaN
[16] Train-rmse=NaN
[17] Train-rmse=NaN
[18] Train-rmse=NaN
[19] Train-rmse=NaN
[20] Train-rmse=NaN
...
Is not correct my specification fo the linear regression model?
LR is too large