Output threshold function, Neural Network
6 ビュー (過去 30 日間)
古いコメントを表示
I am using neural network of 1 hidden layer with 2 neurons, 2 input neurons and 2 output neurons. My aim is to set output threshold such as if it is greater than >0.5, set output to 1, if less than <0.5, set output to 0. How can I do it? My code is below:
clc;
in=[0 0 1 1
1 0 0 1];
out=[1 1 1 0
0 1 0 1];
net=feedforwardnet(2);
net.layers{1}.transferFcn='logsig';
net.layers{2}.transferFcn='logsig';
net.trainParam.perf = 'sse';
net.trainParam.epochs = 100;
net.trainParam.goal = 1e-6;
net.divideParam.trainRatio = 70/100;
net.divideParam.valRatio = 15/100;
net.divideParam.testRatio = 15/100;
net = init(net);
[net,tr] = train(net, in, out)
0 件のコメント
回答 (1 件)
Jayanti
2025 年 7 月 3 日
Hi Aydin,
As you're training a feedforward neural network with 2 inputs, 1 hidden layer of 2 neurons, and 2 output neurons.
After training, the output of the network "net(in)" will be in the range (0, 1). To convert this into binary values (0 or 1) based on a threshold of 0.5, you can use the following code:
% Simulate the network
y = net(in);
% Apply thresholding
y_binary = double(y > 0.5);
This will interpret the network's output as binary classification results.
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Deep Learning Toolbox についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!