【发布时间】:2019-08-12 20:25:00
【问题描述】:
我正在尝试使用 Matlab 构建自己的回归网络。虽然到目前为止我所做的看起来有点毫无意义,但我确实想稍后将其扩展为一个稍微不寻常的网络,所以我自己做,而不是从现成的东西中获取。
我写了以下代码:
% splitinto dev, val and test sets
[train_idxs,val_idxs,test_idxs] = dividerand(size(X,2));
training_X = X( : , train_idxs );
training_Y = Y( : , train_idxs );
val_X = X( : , val_idxs );
val_Y = Y( : , val_idxs );
test_X = X( : , test_idxs );
test_Y = Y( : , test_idxs );
input_count = size( training_X , 1 );
output_count = size( training_Y , 1 );
layers = [ ...
sequenceInputLayer(input_count)
fullyConnectedLayer(16)
reluLayer
fullyConnectedLayer(8)
reluLayer
fullyConnectedLayer(4)
reluLayer
fullyConnectedLayer(output_count)
regressionLayer
];
options = trainingOptions('sgdm', ...
'MaxEpochs',8, ...
'MiniBatchSize', 1000 , ...
'ValidationData',{val_X,val_Y}, ...
'ValidationFrequency',30, ...
'ValidationPatience',5, ...
'Verbose',true, ...
'Plots','training-progress');
size( training_X )
size( training_Y )
size( val_X )
size( val_Y )
layers
net = trainNetwork(training_X,training_Y,layers,options);
view( net );
pred_Y = predict(net,test_X)
我无法分享 X 和 Y 实际上是什么,但输入 X 是一个 3xn 双精度数组,输出 Y 是一个最初来自 Matlab 表的 2xn 数组。
这是输出:
ans =
3 547993
ans =
2 547993
ans =
3 117427
ans =
2 117427
layers =
9x1 Layer array with layers:
1 '' Sequence Input Sequence input with 3 dimensions
2 '' Fully Connected 16 fully connected layer
3 '' ReLU ReLU
4 '' Fully Connected 8 fully connected layer
5 '' ReLU ReLU
6 '' Fully Connected 4 fully connected layer
7 '' ReLU ReLU
8 '' Fully Connected 2 fully connected layer
9 '' Regression Output mean-squared-error
Training on single CPU.
|======================================================================================================================|
| Epoch | Iteration | Time Elapsed | Mini-batch | Validation | Mini-batch | Validation | Base Learning |
| | | (hh:mm:ss) | RMSE | RMSE | Loss | Loss | Rate |
|======================================================================================================================|
| 1 | 1 | 00:00:02 | 0.88 | 4509.94 | 0.3911 | 1.0170e+07 | 0.0100 |
| 8 | 8 | 00:00:04 | NaN | NaN | NaN | NaN | 0.0100 |
|======================================================================================================================|
Error using view (line 73)
Invalid input arguments
Error in layer (line 85)
view( net );
显然发生了一些不正常的事情,因为训练几乎是瞬时的,我无法查看生成的网络。谁能告诉我我做错了什么?或者提供一些调试技巧?
谢谢, 亚当。
【问题讨论】:
-
感谢整理输出格式!
标签: matlab neural-network deep-learning regression