Borrar filtros
Borrar filtros

Neural Networks with constrains

3 visualizaciones (últimos 30 días)
Yonny Muñoz Muñoz
Yonny Muñoz Muñoz el 25 de Mayo de 2023
Respondida: Shubham el 1 de Jun. de 2023
Hello,
I am using the NN toolbox to solve a problem target = F(variables) and It works really good. However, I need that every inputs into "variables" be positive. Is it possible to do it in Matlab?
Thank you very much
Yonny
  1 comentario
Yonny Muñoz Muñoz
Yonny Muñoz Muñoz el 25 de Mayo de 2023
So, the thing is that "variables" are calculated by using the targets that the NN predicts, i.e. "variables" is a "post-processing" vector. It would be great to write into the NN code that those "variables" should be positive, so that once I calculate them with another postprocessing code they are all positive.

Iniciar sesión para comentar.

Respuestas (1)

Shubham
Shubham el 1 de Jun. de 2023
Hi Yonny,
Yes, it is possible to constrain the inputs to your neural network to be positive using the MATLAB NN Toolbox.
One way you can achieve this is by preprocessing your data before training the network. You can use MATLAB's mapminmax function to scale your input data to a range of [0, 1] and then multiply the scaled data by the maximum value of your input variables to ensure that all inputs are positive.
Here's an example code snippet that shows how you can apply this preprocessing step:
% Assume that your input data is stored in an n-by-m matrix X, where n is the number of samples and m is the number of variables.
% Scale the input data to [0, 1]
[X_scaled, PS] = mapminmax(X');
X_scaled = X_scaled';
% Multiply the scaled data by the maximum value of your input variables
max_vals = max(X);
X_pos = X_scaled .* repmat(max_vals, n, 1);
After preprocessing your data, you can use X_pos as the input to your neural network to ensure that all inputs are positive.
I hope this helps!

Categorías

Más información sobre Measurements and Feature Extraction en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2022a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by