フィルターのクリア

For binary classification using a neural network, I want to enforce one output node instead of two output nodes

2 ビュー (過去 30 日間)
Z
Z 2022 年 9 月 21 日
編集済み: Z 2023 年 8 月 30 日
I have a dataset consisting of a positive class and a negative class which I want to classifiy using a neural network (e.g. cancerous tumor or benign). I want to set the classification layer to a single node, either this class or that class. During training, MATLAB detects that the data contains two labels, and insists that I put two nodes at the output. How can I enforce one node at the output?
  1 件のコメント
Z
Z 2022 年 9 月 22 日
I learned that I needed to use a sigmoid instead of a softmax before the output layer. Now the issue is that I cannot use the built-in classification layer, and need to create a custom layer which uses the binary cross-entropy loss.

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

回答 (1 件)

Gagan Agarwal
Gagan Agarwal 2023 年 8 月 30 日
Hi Z
In MATLAB, the default assumption is that your dataset contains multiple classes, and as a result, the output layer is automatically configured accordingly with the desired no of nodes to accommodate the corresponding classes.
However, if you specifically want to ensure that the output layer has only one node, you can achieve this by explicitly setting the size of the output layer to 1 using the following command:
net.layers{end}.size = 1;
Here, the variable 'net' represents your neural network.
  1 件のコメント
Z
Z 2023 年 8 月 30 日
編集済み: Z 2023 年 8 月 30 日
Hello Gagan,
This command doesn't work.
For example, if I do
net=googlenet;
net.layers{end}.size = 1;
I get: Unrecognized method, property, or field 'layers' for class 'DAGNetwork'.

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

カテゴリ

Help Center および File ExchangeBuild Deep Neural Networks についてさらに検索

製品


リリース

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by