What are the differences between fitrnet and trainnet?
I am trying to perform regression on a set of data X (size 52048 x 4) with responses Y (size 52048 x 1).
If I perform a linear regression using mvregress(X,Y), I get a model with a coefficient of determination of 0.70.
If I train a neural network using fitrnet(X,Y), I get a model with a coefficient of determination of about 0.75.
mdl2 = fitrnet(X,Y);
I would like more customizability than what fitrnet offers, so I am trying to use trainnet. To make sure that I am using it correctly, I wanted to recreate the result from fitrnet using trainnet, so I set up the trainnet input parameters to match the defaults from fitrnet:
layers = [
featureInputLayer(size(X,2))
fullyConnectedLayer(10)
reluLayer
fullyConnectedLayer(1)];
options = trainingOptions(‘lbfgs’, GradientTolerance=1e-6, StepTolerance=1e-6);
mdl3 = trainnet(X,Y,layers,’mse’,options);
When I run this, after a few iterations I get a "Training stopped" message and the output model has a coefficient of determination less than 0.30. Sometimes the stoppage message says "Step tolerance reached" and sometimes it says "Suitable learning rate not found".
However, if I initialize the weights and biases for trainnet using the weights and biases learned by fitrnet, trainnet immediately recognizes this as an optimal solution and outputs "Training stopped: Suitable learning rate not found" without making any modification to the weights or biases.
layers = [
featureInputLayer(size(X,2))
fullyConnectedLayer(10, ‘Weights’, mdl2.LayerWeights{1}, ‘Bias’, mdl2.LayerBiases{1})
reluLayer
fullyConnectedLayer(1, ‘Weights’, mdl2.LayerWeights{2}, ‘Bias’, mdl2.LayerBiases{2})];
mdl4 = trainnet(X,Y,layers,’mse’,options);
How is it that trainnet can recognize the solution from fitrnet as optimal, but cannot recreate a similar result using what seems to be identical input parameters?I am trying to perform regression on a set of data X (size 52048 x 4) with responses Y (size 52048 x 1).
If I perform a linear regression using mvregress(X,Y), I get a model with a coefficient of determination of 0.70.
If I train a neural network using fitrnet(X,Y), I get a model with a coefficient of determination of about 0.75.
mdl2 = fitrnet(X,Y);
I would like more customizability than what fitrnet offers, so I am trying to use trainnet. To make sure that I am using it correctly, I wanted to recreate the result from fitrnet using trainnet, so I set up the trainnet input parameters to match the defaults from fitrnet:
layers = [
featureInputLayer(size(X,2))
fullyConnectedLayer(10)
reluLayer
fullyConnectedLayer(1)];
options = trainingOptions(‘lbfgs’, GradientTolerance=1e-6, StepTolerance=1e-6);
mdl3 = trainnet(X,Y,layers,’mse’,options);
When I run this, after a few iterations I get a "Training stopped" message and the output model has a coefficient of determination less than 0.30. Sometimes the stoppage message says "Step tolerance reached" and sometimes it says "Suitable learning rate not found".
However, if I initialize the weights and biases for trainnet using the weights and biases learned by fitrnet, trainnet immediately recognizes this as an optimal solution and outputs "Training stopped: Suitable learning rate not found" without making any modification to the weights or biases.
layers = [
featureInputLayer(size(X,2))
fullyConnectedLayer(10, ‘Weights’, mdl2.LayerWeights{1}, ‘Bias’, mdl2.LayerBiases{1})
reluLayer
fullyConnectedLayer(1, ‘Weights’, mdl2.LayerWeights{2}, ‘Bias’, mdl2.LayerBiases{2})];
mdl4 = trainnet(X,Y,layers,’mse’,options);
How is it that trainnet can recognize the solution from fitrnet as optimal, but cannot recreate a similar result using what seems to be identical input parameters? I am trying to perform regression on a set of data X (size 52048 x 4) with responses Y (size 52048 x 1).
If I perform a linear regression using mvregress(X,Y), I get a model with a coefficient of determination of 0.70.
If I train a neural network using fitrnet(X,Y), I get a model with a coefficient of determination of about 0.75.
mdl2 = fitrnet(X,Y);
I would like more customizability than what fitrnet offers, so I am trying to use trainnet. To make sure that I am using it correctly, I wanted to recreate the result from fitrnet using trainnet, so I set up the trainnet input parameters to match the defaults from fitrnet:
layers = [
featureInputLayer(size(X,2))
fullyConnectedLayer(10)
reluLayer
fullyConnectedLayer(1)];
options = trainingOptions(‘lbfgs’, GradientTolerance=1e-6, StepTolerance=1e-6);
mdl3 = trainnet(X,Y,layers,’mse’,options);
When I run this, after a few iterations I get a "Training stopped" message and the output model has a coefficient of determination less than 0.30. Sometimes the stoppage message says "Step tolerance reached" and sometimes it says "Suitable learning rate not found".
However, if I initialize the weights and biases for trainnet using the weights and biases learned by fitrnet, trainnet immediately recognizes this as an optimal solution and outputs "Training stopped: Suitable learning rate not found" without making any modification to the weights or biases.
layers = [
featureInputLayer(size(X,2))
fullyConnectedLayer(10, ‘Weights’, mdl2.LayerWeights{1}, ‘Bias’, mdl2.LayerBiases{1})
reluLayer
fullyConnectedLayer(1, ‘Weights’, mdl2.LayerWeights{2}, ‘Bias’, mdl2.LayerBiases{2})];
mdl4 = trainnet(X,Y,layers,’mse’,options);
How is it that trainnet can recognize the solution from fitrnet as optimal, but cannot recreate a similar result using what seems to be identical input parameters? fitrnet, trainnet MATLAB Answers — New Questions