Going from trainNetwork to trainnet
49 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
psousa
el 21 de Nov. de 2024
Comentada: psousa
el 28 de En. de 2025 a las 13:50
I've attached 3 files(see post below for latest version of these files):
- trainNetworkEXAMPLE - my original trainNetwork implementation
- trainnetEXAMPLE - the trainnet implementation
- example.csv - data file with predictors and targets
The codes for the two examples are identical, the difference is only in the formatting of the input matrices.
trainNetworkEXAMPLE works as expected.
trainnetEXAMPLE works but convergence of the solver is different and solution is poor.
Both codes end with:
Training stopped: Met validation criterion
What am I getting wrong?
2 comentarios
Respuesta aceptada
Sourabh
el 28 de En. de 2025 a las 9:05
Editada: Sourabh
el 28 de En. de 2025 a las 9:06
Hi @psousa
I too encountered the similar issue when using “trainnet” and “trainNetwork” method.
The workaround that worked in my case was to:
- Use @mse as the loss function instead of "mse" in “trainnet”.
[net,info] = trainnet(XTrain,TTrain,layers,@mse,options);
2. Set 'GradientThreshold' to ‘Inf’ in ‘trainingOptions’ of both the programs.
options = trainingOptions('adam',
...
'GradientThreshold',Inf,
...
);
Kindly refer to the below image:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1824390/image.png)
Más respuestas (0)
Ver también
Categorías
Más información sobre Image Data Workflows en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!