Convolutional neural networks About convolution can be abstracted into mathematical expressions:
I can represent the matrix of an image, K is the convolution kernel
The computational layer of the convolution Object Recogition with Gradient-Based Learning
input layer Input Layer Convolution Layer Conv Layer Restricted Layer RELU Layer pooling layer Pooling Layer full connected layer Creating a network Basic learning to distinguish between dogs and cats (* Create model *) myCatDogModel = NetChain[{ ConvolutionLayer[32, 3], Ramp, PoolingLayer[2, 2], ConvolutionLayer[64, 3], Ramp, PoolingLayer[2, 2], FlattenLayer[], 128, Ramp, 2, SoftmaxLayer[]}, "Input" -> NetEncoder[{"Image", {224, 224}, ColorSpace -> "RGB"}] , "Output" -> NetDecoder[{"Class", {"cat", "dog"}}]] (* Collect samples, training set and test set *) (* Convert data sets to Association format *) dataSetsConvert[dateSets_] := Module[ {}, File[#] -> StringSplit[FileBaseName[#], "."] [[1]] & /@ dateSets] traingDataFiles = RandomSample[dataSetsConvert[traingData]]; testDataFiles = RandomSample[dataSetsConvert[testData]]; SetDirectory[ "/Users/alexchen/datasets/Convolutional_Neural_Networks/dataset"]; FileNames["*.jpg", "training_set/cats/"]; FileNames["*.jpg", "training_set/dogs/"]; traingData = Join[FileNames["*.jpg", "training_set/cats/"], FileNames["*.jpg", "training_set/dogs/"]]; testData = Join[FileNames["*.jpg", "test_set/cats"], FileNames["*.jpg", "test_set/dogs"]]; (* Generate training and validation sets *) traingDataFiles = RandomSample[dataSetsConvert[traingData]]; testDataFiles = RandomSample[dataSetsConvert[testData]]; (* sample is randomly selected for display *) RandomSample[traingDataFiles, 5] (* train the model *) mytrainedModel = NetTrain[catdogModel, traingDataFiles, All, ValidationSet -> testDataFiles, MaxTrainingRounds -> 20] (* Generate training model evaluation report *) myModelPlot = mytrainedModel["FinalPlots"] (* Generate the trained model to calculate the model correctness *) myTrainedNet = mytrainedModel["TrainedNet"] ClassifierMeasurements[myTrainedNet, testDataFiles, "Accuracy"] ...