Más contenido relacionado
Más de Akifumi Eguchi (19)
Mxnetで回帰 #TokyoR 53th
- 7. #結合形式, data設定, 隠れ層の数指定
fc1 <- mx.symbol.FullyConnected(data, num_hidden=1)
# 出力層を線形回帰に指定
lro <- mx.symbol.LinearRegressionOutput(fc1)
mx.set.seed(0)
model1 <- mx.model.FeedForward.create(lro, X=train.x, y=train.y,
ctx=mx.cpu(), num.round=50, array.batch.size=20,
learning.rate=2e-6, momentum=0.9, eval.metric=mx.metric.rmse)
# testデータへの当てはめ
preds1 = predict(model1, test.x)
# RMSE算出
sqrt(mean((preds1-test.y)^2))
# モデルの図示
graph.viz(model1$symbol$as.json())
MXNetの線形回帰: パラメータ設定・結果確認1
参照: “Neural Network with MXNet in Five Minutes”
hEp://mxnet.readthedocs.org/en/latest/packages/r/fiveMinutesNeuralNetwork.html
- 8. #結合形式, data設定, 隠れ層のユニット数指定
fc1 <- mx.symbol.FullyConnected(data, num_hidden=1)
# 出力層を線形回帰に指定
lro <- mx.symbol.LinearRegressionOutput(fc1)
mx.set.seed(0)
model1 <- mx.model.FeedForward.create(lro, X=train.x, y=train.y,
ctx=mx.cpu(), num.round=50, array.batch.size=20,
learning.rate=2e-6, momentum=0.9, eval.metric=mx.metric.rmse)
# testデータへの当てはめ
preds1 = predict(model1, test.x)
# RMSE算出
sqrt(mean((preds1-test.y)^2))
# モデルの図示
graph.viz(model1$symbol$as.json())
MXNetの線形回帰: パラメータ設定・結果確認2
回帰分析の場合、出力層直前の
隠れ層のユニット数は1でないとだめ
参照: “Neural Network with MXNet in Five Minutes”
hEp://mxnet.readthedocs.org/en/latest/packages/r/fiveMinutesNeuralNetwork.html
- 9. #結合形式, data設定, 隠れ層のユニット数指定
fc1 <- mx.symbol.FullyConnected(data, num_hidden=1)
# 出力層を線形回帰に指定
lro <- mx.symbol.LinearRegressionOutput(fc1)
mx.set.seed(0)
model1 <- mx.model.FeedForward.create(lro, X=train.x, y=train.y,
ctx=mx.cpu(), num.round=50, array.batch.size=20,
learning.rate=2e-6, momentum=0.9, eval.metric=mx.metric.rmse)
# testデータへの当てはめ
preds1 = predict(model1, test.x)
# RMSE算出
sqrt(mean((preds1-test.y)^2))
# モデルの図示
graph.viz(model1$symbol$as.json())
MXNetの線形回帰: パラメータ設定・結果確認3
この他に
mx.symbol.MAERegressionOutput
mx.symbol.Logis<cRegressionOutput
が関数として用意されている。
回帰分析の場合、出力層直前の
隠れ層のユニット数は1でないとだめ
参照: “Neural Network with MXNet in Five Minutes”
hEp://mxnet.readthedocs.org/en/latest/packages/r/fiveMinutesNeuralNetwork.html
- 10. #結合形式, data設定, 隠れ層のユニット数指定
fc1 <- mx.symbol.FullyConnected(data, num_hidden=1)
# 出力層を線形回帰に指定
lro <- mx.symbol.LinearRegressionOutput(fc1)
mx.set.seed(0)
model1 <- mx.model.FeedForward.create(lro, X=train.x, y=train.y,
ctx=mx.cpu(), num.round=50, array.batch.size=20,
learning.rate=2e-6, momentum=0.9, eval.metric=mx.metric.rmse)
# testデータへの当てはめ
preds1 = predict(model1, test.x)
# RMSE算出
sqrt(mean((preds1-test.y)^2))
# モデルの図示
graph.viz(model1$symbol$as.json())
MXNetの線形回帰: パラメータ設定・結果確認4
パラメータの設定
この他に
mx.symbol.MAERegressionOutput
mx.symbol.Logis<cRegressionOutput
が関数として用意されている。
回帰分析の場合、出力層直前の
隠れ層のユニット数は1でないとだめ
参照: “Neural Network with MXNet in Five Minutes”
hEp://mxnet.readthedocs.org/en/latest/packages/r/fiveMinutesNeuralNetwork.html
- 11. #結合形式, data設定, 隠れ層のユニット数指定
fc1 <- mx.symbol.FullyConnected(data, num_hidden=1)
# 出力層を線形回帰に指定
lro <- mx.symbol.LinearRegressionOutput(fc1)
mx.set.seed(0)
model1 <- mx.model.FeedForward.create(lro, X=train.x, y=train.y,
ctx=mx.cpu(), num.round=50, array.batch.size=20,
learning.rate=2e-6, momentum=0.9, eval.metric=mx.metric.rmse)
# testデータへの当てはめ
preds1 = predict(model1, test.x)
# RMSE算出
sqrt(mean((preds1-test.y)^2))
# モデルの図示
graph.viz(model1$symbol$as.json())
MXNetの線形回帰: パラメータ設定・結果確認5
パラメータの設定
この他に
mx.symbol.MAERegressionOutput
mx.symbol.Logis<cRegressionOutput
が関数として用意されている。
回帰分析の場合、出力層直前の
隠れ層のユニット数は1でないとだめ
参照: “Neural Network with MXNet in Five Minutes”
hEp://mxnet.readthedocs.org/en/latest/packages/r/fiveMinutesNeuralNetwork.html
- 15. MXNetの線形回帰 + 深層ニューラルネットの場合
# 結合形式, data設定, 隠れ層の数指定
fc1 <- mx.symbol.FullyConnected(data, name="fc1", num_hidden=128)
act1 <- mx.symbol.Ac<va<on(fc1, name="relu1", act_type="relu")
drop1 <- mx.symbol.Dropout(act1, p = 0.5, name="drop1")
fc2 <- mx.symbol.FullyConnected(drop1, name="fc2", num_hidden=64)
act2 <- mx.symbol.Ac<va<on(fc2, name="relu2", act_type="relu")
drop2 <- mx.symbol.Dropout(act2, p = 0.5, name="drop2")
fc3 <- mx.symbol.FullyConnected(drop2, name="fc3", num_hidden=1)
# 出力層を線形回帰に指定
lro2 <- mx.symbol.LinearRegressionOutput(fc3)