97

Here is one example using a convolutional neural network (CNN) to crack the CAPTCHA. We will use a CAPTCHA library to generate sample CAPTCHA images and then train a neural network to decode these images. The trained network can be downloaded from crack_CAPTCHA.wlnet. In the following, we will describe how to prepare the training data, construct and train ...


55

Introduction An object detection problem can be approached as either a classification problem or a regression problem. As a classification problem, the image is divided into small patches, each of which will be run through a classifier to determine whether there are objects in the patch. Then the bounding boxes will be assigned to locate around patches that ...


39

The most basic neural nets are just a DotCross layer and some layer that provides nonlinearity. I recommend starting with that. This is essentially what you see in textbooks. You can see examples like this in the documentation for NetTrain. Let's make some data for your example of a function that converts from RGBValues to Hues: rndExample := With[{...


38

Indeed, this functionality still exists, but it has been moved into its own package. Load the package: Needs["aBetterProgrammer`"] You will have access to such functions as GimmeDaCodez (answers any nebulous MMA.SE question by guessing the unspoken needs of the asker) WizardForm (an output wrapper; produces perfectly terse code; all function calls are ...


36

Thank you for your summary. I would like to clarify and correct a few of your points. however, Mathematica - being proprietary - does not make it clear as to which algorithms they choose to use to implement their network layers. Therefore I honestly am not sure of the some of these layers' underpinnings. We use the same definitions as all the other ...


35

This is actually a useful question, because it gives an opportunity for us to communicate with the community about what is coming, so we can get feedback. So here is some preliminary information about our plans (subject to change, of course). First, we'll have the concept of a sequence of things (e.g. sequence of vectors, sequence of matrices, sequence of ...


31

Mathematica's neural network functionality is based on MXNET. So you can use pre-trained models for MXNET or create and train state-of-the-art models with NetGraph. For example, pre-trained Inception-V3: https://github.com/dmlc/mxnet-model-gallery/blob/master/imagenet-1k-inception-v3.md URLDownload[ "http://data.dmlc.ml/mxnet/models/imagenet/inception-...


27

It seems the model file in MXNet (checkpoint) is defined by two files: a ".json" file and a ".params" file. The json file contains the definition of the network, and the params file contains the actual weight and bias of each neuron. The params file is in the binary format of MXNet's NDArray representation. Thus, to export a network in Mathematica to MXNet, ...


27

I wrestled with this for a while and got some kind of results, but nowhere near the great performance for which GANs are famous. Ultimately, they're absurdly sensitive to hyperparameters and initialization, and if you don't exactly imitate the published settings, you are unlikely to get good results. I figure I should post my attempt -- maybe the community ...


26

From A comprhensive overview of network layers and functions Motivation As Mathematica v.11 was released earlier this month with a host of new [[experimental]] functions and a limited number of examples on curated data that do not cover all layers, options, etc. I am posting this with the intent of augmenting Mathematica's documentation via the cummulative ...


26

Sebastian mentioned in his answer that deepdream can be possible using NetDerivative. Here are my attempts following his outlines. Instead of using the inception model, I'm using VGG-16 here for simplicity. Inception model allows arbitrary image size, but may need some extra normalization steps. The MXNet version of the VGG model can be downloaded from ...


24

It's on our list of things to do, but there are many other areas we want to cover, such as custom feature functions, customizable feature selection, boosting, NLP, deep learning of neural networks, convolutional nets, GPU acceleration, and so on. Until then, your only real solution is to deploy your trained classifier as an API function. Some simpler ...


23

Since version 11 most commands finally support the Interpretation option: Interpretation -> "Literal" being the classical (default) way of operation, and Interpretation -> "Guess" using advanced machine learning to get much better results than ReadProgrammerIntentions ever achieved. Makes programming a lot easier. You can emulate the old behavior with ...


21

You can pass the undocumented option "ShowTrainingProgress" -> False to turn off the training progress blob thing. As for monitoring the progress yourself, there is a feature coming in 11.1 called Checkpointing that lets you specify a callback to every so often that gets access to the partially trained net. You WOULD use it like so: NetTrain[ ..., ...


21

Bring in pre-trained models is sometimes very useful. Alexey's answer is somewhat brief, here I'm trying to add some examples hopefully will be helpful. We can load the trained network by net = NeuralNetworks`ImportMXNetModel[ "model/Inception-7-symbol.json", "model/Inception-7-0001.params" ] and attach the final softmax layer to calculate the ...


20

I tend to use a pattern matching approach: myCode/.{x_?BugQ:>BugStrip[x],x_?TypoQ:>Detypo[x],x_?WrongSignQ:>-x,x_?OffBy2PiQ:>x*2\[Pi]} With the usual caveat that pattern matching can be slower than other methods, but conceptually easier to understand. Hopefully someone will aggregate the answers to compare performance. Good luck!


19

If you have an inception model, its mostly possible using hidden functionality (but without GPU training). The steps would look like this: Cut the inception model at some level using Take. Then add a Ramp (or other) positive activation and SummationLayer: DeepDream simply wants to maximize the total amount of neuronal firing at the last layer (the original ...


18

Here's the code. What I mentioned in the Q&A session is using ReshapeLayer to turn the input vector into a 1-channel, flat tensor that ConvolutionLayer can operate on, not to actually use images, per se. I've limited things here just to the original industries, but you can try more if you want. Downloading takes a while, so I have an Export there you ...


18

Layers BatchNormalizationLayer There are several layers introduced in v.11 that can not be used uninitialized, this is one of them. Input must be either a rank 1 or rank 3 tensor. To be honest, I do not think we can see its true effect on one input as demonstrated by these two examples below. I believe the effect of Batch normalization is only implemented ...


18

This function was deprecated in V4.2, being succeeded by CellularAutomaton. Since your answer is hidden somewhere in rules like 110, why reinvent the wheel with ReadProgrammerIntentions?


17

I think it would be simpler to construct the simple neural network rather than setting the properties in Classify. Here is an example using a three-layer net to classify the MNIST handwritten digits. We first load the data, and we will take 5000 examples as training data and 1000 examples as test data resource = ResourceObject["MNIST"]; trainingDataImg = ...


16

There are two parts to your question: 1. How to use out-of-core classification and 2. Why is the result bad. For the first part, you can use a generator to solve the problem. And for the second part, the reason for a bad result is because the data is not randomized. fileName = "/Users/xslittlegrass/Downloads/test_data_SE.dat"; data = RandomSample@Flatten@...


15

As already mentioned, options are accessed via: Method -> {"NeuralNetwork", "L2Regularization" -> 0.12, "HiddenLayers" -> {4, 3, 3}} To manually set the activation functions of the first and second hidden layers: "HiddenLayers"-> {{4, "RectifiedLinear"}, {3, "Tanh"}, 3} Currently, the following activation functions are supported: {"...


15

... however in Mathematica the net always performs a linear fit, no matter how many layers und neurons I use. I'm guessing you're using only DotPlusLayers. These are linear - so no matter how many you use, you will always get a linear mapping. To get a nonlinear mapping, you either have to add nonlinear input (e.g. giving the network x, x^2, x^3 as input ...


15

Okay here's how you do out-of-core training with HDF5: input = RandomReal[1, {1000, 2}]; output = RandomReal[1, {1000, 2}]; Get["GeneralUtilities`"]; ExportStructuredHDF5["test.h5", <|"Input" -> input, "Output" -> output|>] NetTrain[LinearLayer["Input" -> 2, "Output" -> 2], File["test.h5"]] The use of ExportStructuredHDF5 is just for ...


15

Update: So after adding the missing features I decided to give your actual problem a go. This is what I have: You'll note a little "Add Layer" ActionMenu on the right. That's really the only actual extension to the basic BlockBuilder[] interface I needed. Wasn't hard to get in. The Run function turned out to be something of a tough problem. I had code ...


15

You can construct an IndexMaxLayer using the existing layers, like so: indexMaxLayer[] := NetGraph[{ "max" -> AggregationLayer[Max, 1], "repl" -> ReplicateLayer[Automatic], "switch" -> ThreadingLayer[If[#1 != #2, 0., 1.] &] }, { "max" -> "repl", {NetPort@"Input", "repl"} -> "switch" }] indexMaxLayer[][{1,2,1,4,2}] &...


14

At least Method -> {"NeuralNetwork", "L2Regularization" -> 0.01, "HiddenLayers" -> {4, 3, 3}} seems to work. "L1Regularization" doesn't seem to be settable. Haven't found out about activation functions yet. Update More options can be found using Options@MachineLearning`PackageScope`NeuralNetworkPredictor {"BinaryEncoder" -> "Identity", "...


14

Example from NetTrain documentation (Applications - Computer Vision - Style Transfer): vggNet = NetModel["VGG-16 Trained on ImageNet Competition Data"]; Take a subnet that will be used as a feature extractor for the style and content images: featureNet = Take[vggNet, {1, "relu4_1"}] There are three loss functions used. The first loss ensures that the "...


14

Supporting custom layers is on our to-do list, and should be ready for either 11.2 or 11.3. For interest: what applications do you want custom layers for? And how performant do you need your custom layer to be? (for example, do you want to be able to write your own CUDA implementation? Or are you happy with writing your own CPU layer?)


Only top voted, non community-wiki answers of a minimum length are eligible