I'm very new to Neural Networks and Mathematica 11 (I used MMA8 some time ago) and I'm trying to learn about NN using Mathematica. I'm using MMA 11.2 in a Rapsberry Pi (yes, I know that doing NN in a RP is a terrible idea).

I have some data and I've trained a NN using Classify:

c = Classify[data, Method->"NeuralNetwork"];

Now I would like to extract the trained network from c, to plot it, re-train it, modify it, etc. I have not found how to do that.

In addition, I've noticed that using Classify or Predict takes a lot of time to get started. The actual training is not that long, for my small dataset, but it takes like 15 minutes to get started. Why is that? I understand that Classify or Predict will guess the optimal NN to use, and then train it, may be that is very time-consuming?

Thank you.

  • $\begingroup$ The reason it takes so long to get started is possibly the feature extraction step. Try using FeatureExtractor->"Something" (check the doc for FeatureExtractor for options) and see if it makes a difference. $\endgroup$
    – Carl Lange
    Jul 7, 2018 at 10:33

1 Answer 1


You can extract the network from the classifier by doing:

net = (First@c)["Model"]["Network"]

Have a look at the rest of (First@c)["Model"] for other information about the network, including initial conditions.

The start of the Classify step may take so long because of your FeatureExtractor settings. Various feature extractors take different amounts of time to complete, and the frontend doesn't appear to report its progress while doing this. Consider using different FeatureExtractors and see if it goes faster or slower - but be warned, it'll definitely have an effect on your classification accuracy.

Example of the code above

  • 1
    $\begingroup$ Thank you for your comment! Extracting the model works just fine. i've tried different FeatureExtractors and while there are some differences,it still takes several minutes to start. Do all methods, apart from NeuralNetwork, require this feature extraction? Because others start much faster. I've tried a simple data input in the form of real->boolean, so the input is pretty straightforward. $\endgroup$
    – siritinga
    Jul 7, 2018 at 17:46
  • $\begingroup$ Thanks, it looks very interesting but probably I'm learning it wrong. I think I should start with some more basic material. I did a Coursera course about Machine Learning but I see that to build and train a model from scratch I should know more about encoders, decoders, kinds of layers, their rank and dimension, and so on... $\endgroup$
    – siritinga
    Jul 7, 2018 at 17:50
  • $\begingroup$ Regarding slowness: unfortunately that was my best guess. Have you experimented with networks using NetChain? Do they exhibit the same problem? It might be just that the networks are too memory hungry for the Pi, but I really don't know. $\endgroup$
    – Carl Lange
    Jul 7, 2018 at 17:52
  • $\begingroup$ I personally find this guide to be a perpetual source of light whenever I'm stuck with some more basic concepts, maybe it'll help you! $\endgroup$
    – Carl Lange
    Jul 7, 2018 at 17:53
  • $\begingroup$ I tried NetChain with a simple network: NetChain[{LinearLayer[50], LinearLayer[], LogisticSigmoid}]and training starts in seconds. And if I interpret correctly the reported loss, it's better than the one produced by Classify. $\endgroup$
    – siritinga
    Jul 7, 2018 at 17:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.