For example, we have data:
SeedRandom[0]; n = 1000; X = RandomReal[{-1, 1}, {n, 10}]; Y = RandomInteger[1, n];
c = Classify[X -> Y, Method -> "NeuralNetwork"]
Let's see the options:
Options[c]
Let's reconstruct this network:
net = NetChain[ {LinearLayer[30], Ramp, LinearLayer[30], Ramp, 2, SoftmaxLayer[]}, "Input" -> 10, "Output" -> NetDecoder[{"Class", {0, 1}}] ]
But weights are uninitialized. Let's initialize them with NetReplacePart
. This is the new function in V11.1. As I see you are using V11.0. But you can experiment with V11.1 in the Wolfram Open Cloud for free.
weights = Options[c][[1]]["Models"][[1]]["NeuralNetwork"]["Weights"]; biases = Options[c][[1]]["Models"][[1]]["NeuralNetwork"]["Biases"]; net = NetReplacePart[net, { {1, "Weights"} -> weights[[1]], {1, "Biases"} -> biases[[1]], {3, "Weights"} -> weights[[2]], {3, "Biases"} -> biases[[2]], {5, "Weights"} -> weights[[3]], {5, "Biases"} -> biases[[3]] } ]
Let's compare our classifiers:
ClassifierMeasurements[c, X -> Y, "ConfusionMatrixPlot"]
In V11.1 network can be converted into a ClassifierFunction
.
ClassifierMeasurements[Classify[net], Standardize[X] -> Y, "ConfusionMatrixPlot"]
Result is the same!
Additional links:
Wolfram Open Cloud: https://www.open.wolframcloud.com
How to change weights of a neural network: http://mathematica.stackexchange.com/a/141291/23402https://mathematica.stackexchange.com/a/141291/23402
"Is it possible to convert the result of NetTrain to a PredictorFunction?": http://mathematica.stackexchange.com/a/140095/23402https://mathematica.stackexchange.com/a/140095/23402