Example of a Mushroom Classifier
Example of a Mushroom Classifier
Train your own neural networks (NNs) to identify species using images
Train your own neural networks (NNs) to identify species using images
In[]:=
earthstar=
,
,
,
,
,
,
,
,
;
In[]:=
gyromitra=
,
,
,
,
,
,
,
,
,
;
In[]:=
grifolafrondosa=
,
,
,
,
,
,
,
,
,
;
In[]:=
all=Join[Thread[earthstar"earthstar"],Thread[gyromitra"gyromitra"],Thread[grifolafrondosa"grifolafrondosa"]];
In[]:=
{train,test}=TakeDrop[RandomSample[all],25];
In[]:=
net=NetModel["ResNet-50 Trained on ImageNet Competition Data"];netFeature=NetDrop[net,-2];netNew=NetChain[<|"feature"netFeature,"classifier"LinearLayer[],"probabilities"SoftmaxLayer[]|>,"Output"NetDecoder[{"Class",{"earthstar","gyromitra","grifolafrondosa"}}]]
Out[]=
NetChain
In[]:=
trained=NetTrain[netNew,train,All,LearningRateMultipliers{"classifier"1,_0},ValidationSetScaled[0.1],MaxTrainingRounds10,Method"SGD"]
Out[]=
In[]:=
ClassifierMeasurements[trained["TrainedNet"],test,"Accuracy"]
Out[]=
1.
In[]:=
ClassifierMeasurements[trained["TrainedNet"],test,"ConfusionMatrixPlot"]
Out[]=
