Mathematica Asked by John Davis on December 24, 2020
I am using data samples from a multispectral color sensor for color classification as an exercise in beginning to learn about neural networks.
I have succeeded with Classify
for two data formats, {list of 10 integers} -> "color-name"}
and {list of 10 integers} -> integer}
.
I also succeeded with NetChain
for the second, all integer, format. However, I can’t seem to get NetChain
set up with NetEncode
properly so that the color name gets changed to an integer. Classify
does this. I would like to know how it is done.
data={{146,734,659,457,5356,770,537,973,1321,1956}->"Violet",{194,418,598,722,7470,964,1074,2572,3542,2833}->"Orange",{195,900,1238,1374,7551,938,1558,1557,1820,1875}->"Gray",{240,321,711,1710,9970,1287,2938,3723,4032,2896}->"Yellow",{287,604,639,581,12897,1109,737,2233,7648,6920}->"Red"};
net = NetChain[
{
LinearLayer[20],
LinearLayer[],
SoftmaxLayer[]
},
"Input" -> Length@data[[1, 1]],
"Output" -> NetDecoder[{"Class", DeleteDuplicates@data[[;; , 2]]}]
]
netT = NetTrain[net, data[[;; , 1]] -> data[[;; , 2]]]
netT@data[[;; , 1]]
{"Violet", "Orange", "Gray", "Yellow", "Red"}
Correct answer by Alexey Golyshev on December 24, 2020
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP