categorical conversion to integer
    2 ビュー (過去 30 日間)
  
       古いコメントを表示
    
I have trained a neural network with two classes (0 and 1)
When i input an image of size 256x256 as:
y=classify(net,input)
the output y is categorica (either 0 or 1)l.
When I type cast it int 8
y=cast(y,'int'8)
I ger wrong values. I need values as it is classified by classifier in categorical form (0 as 0, 1 as 1).
Any suggestion?
Thanks
0 件のコメント
回答 (3 件)
  Star Strider
      
      
 2023 年 4 月 27 日
        Perhaps something like this — 
y = categorical([0 1])
y = cellfun(@str2double,categories(y))
y = int8(y)
.
0 件のコメント
  Walter Roberson
      
      
 2023 年 4 月 27 日
        
      編集済み: Walter Roberson
      
      
 2023 年 4 月 28 日
  
      create an ordinal categorical with valueset 0 and 1. Afterwards you can int8() the labels
1 件のコメント
  Walter Roberson
      
      
 2023 年 4 月 28 日
				uint8() gives back the class number. If you ordered them then you can work on them mathematically.
y = categorical(randi([0 1], 10, 1), [0 1], ["0", "1"])
uint8(y) - 1
  Stephen23
      
      
 2023 年 4 月 27 日
        M = categorical([0,1;1,0])
X = double(M);
Y = int8(str2double(categories(M)));
Z = Y(X)
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!



