フィルターのクリア

Neural Networks with constrains

3 ビュー (過去 30 日間)
Yonny Muñoz Muñoz
Yonny Muñoz Muñoz 2023 年 5 月 25 日
回答済み: Shubham 2023 年 6 月 1 日
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 件のコメント
Yonny Muñoz Muñoz
Yonny Muñoz Muñoz 2023 年 5 月 25 日
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.

サインインしてコメントする。

回答 (1 件)

Shubham
Shubham 2023 年 6 月 1 日
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!

カテゴリ

Help Center および File ExchangeMeasurements and Feature Extraction についてさらに検索

製品


リリース

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by