<?xml version="1.0" encoding="UTF-8"?>
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns="http://purl.org/rss/1.0/" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel rdf:about="https://community.wolfram.com">
    <title>Community RSS Feed</title>
    <link>https://community.wolfram.com</link>
    <description>RSS Feed for Wolfram Community showing any discussions tagged with Artificial Intelligence sorted by most likes.</description>
    <items>
      <rdf:Seq>
        <rdf:li rdf:resource="https://community.wolfram.com/groups/-/m/t/3336417" />
        <rdf:li rdf:resource="https://community.wolfram.com/groups/-/m/t/3062832" />
        <rdf:li rdf:resource="https://community.wolfram.com/groups/-/m/t/884348" />
        <rdf:li rdf:resource="https://community.wolfram.com/groups/-/m/t/1787163" />
        <rdf:li rdf:resource="https://community.wolfram.com/groups/-/m/t/3062403" />
        <rdf:li rdf:resource="https://community.wolfram.com/groups/-/m/t/2166833" />
        <rdf:li rdf:resource="https://community.wolfram.com/groups/-/m/t/1221098" />
        <rdf:li rdf:resource="https://community.wolfram.com/groups/-/m/t/2864162" />
        <rdf:li rdf:resource="https://community.wolfram.com/groups/-/m/t/1369571" />
        <rdf:li rdf:resource="https://community.wolfram.com/groups/-/m/t/1851854" />
        <rdf:li rdf:resource="https://community.wolfram.com/groups/-/m/t/2328597" />
        <rdf:li rdf:resource="https://community.wolfram.com/groups/-/m/t/562203" />
        <rdf:li rdf:resource="https://community.wolfram.com/groups/-/m/t/1341081" />
        <rdf:li rdf:resource="https://community.wolfram.com/groups/-/m/t/1646303" />
        <rdf:li rdf:resource="https://community.wolfram.com/groups/-/m/t/1843550" />
        <rdf:li rdf:resource="https://community.wolfram.com/groups/-/m/t/3495066" />
        <rdf:li rdf:resource="https://community.wolfram.com/groups/-/m/t/2931334" />
        <rdf:li rdf:resource="https://community.wolfram.com/groups/-/m/t/2137315" />
        <rdf:li rdf:resource="https://community.wolfram.com/groups/-/m/t/2469295" />
        <rdf:li rdf:resource="https://community.wolfram.com/groups/-/m/t/1093926" />
      </rdf:Seq>
    </items>
  </channel>
  <item rdf:about="https://community.wolfram.com/groups/-/m/t/3336417">
    <title>Announcing Wolfram Notebook Assistant + LLM Kit</title>
    <link>https://community.wolfram.com/groups/-/m/t/3336417</link>
    <description>Wolfram Notebook Assistant + LLM Kit is now rolling out!&#xD;
--------------------------------------------------------&#xD;
&#xD;
&amp;gt; [**GET IT HERE&amp;#187;**][1]&#xD;
&#xD;
![enter image description here][2]&#xD;
&#xD;
(For Stephen Wolfram&amp;#039;s full introduction, see his blog: https://wolfr.am/NotebookAssistant)&#xD;
&#xD;
Notice: With this new subscription, we&amp;#039;re rolling out updates to our notebook interfaces for version 14.1. When your system updates, you&amp;#039;ll see new items on your standard toolbar. &#xD;
&#xD;
&#xD;
----------&#xD;
We&amp;#039;re excited to introduce this product that provides new interfaces for computational AI assistance and also provides LLM access for programmatic uses as well. Over the course of its development we&amp;#039;ve already found a lot of good (and fun) uses for it and we&amp;#039;re sure you&amp;#039;ll find many more. Let me give a quick summary of the product&amp;#039;s two parts:&#xD;
&#xD;
The **Notebook Assistant** is aimed at making working in Wolfram Notebooks easier. It provides context-aware suggestions to streamline your workflow based on the content of your notebook. Whether you&amp;#039;re coding or writing, the assistant can help you with tasks such as auto-completing text, suggesting functions, and offering debugging tips.&#xD;
&#xD;
The **Wolfram LLM Kit** lets you use Wolfram as your provider, letting you use [Chat Notebooks][3] and [programmatic LLM functions][4] as simply as possible. You won&amp;#039;t need to set up accounts or give your email to third-party providers like Open AI or Anthropic. We take care of all of that.&#xD;
&#xD;
**Who is this subscription really for?** If you use Wolfram Notebooks, then there&amp;#039;s something in here for you. &#xD;
&#xD;
 - Its not just for code! Like any good LLM, it can help with writing tasks by completing text or outlining documents. And unlike most, it can understand your data and computations while doing it.&#xD;
&#xD;
 - If you&amp;#039;re just starting with Wolfram Language code, tell the assistant what you&amp;#039;re trying to do in plain language and it will help with the first steps toward coding your ideas. It isn&amp;#039;t exactly a tutor but it can tell you to functions to use. If you hit problems on the way, it can help find alternatives.&#xD;
&#xD;
 - If you&amp;#039;re a veteran, it can help you by suggesting rarely-used functions or Options that you might not have thought of. It can access the stack while helping you debug your code. You can use the auto-complete to breeze through the drudgery of mundane code sections.&#xD;
&#xD;
We encourage you to check out Stephen Wolfram&amp;#039;s blog and the gallery of examples to get inspired. We can&amp;#039;t wait to see how you use these new tools to enhance your creativity and productivity in Wolfram Notebooks. Please share your experiences with the Wolfram Community so we can learn new and different ways to use these tools.&#xD;
&#xD;
 - Get Notebook Assistant + LLM Kit: https://www.wolfram.com/notebook-assistant-llm-kit/&#xD;
 - Configuration help: https://support.wolfram.com/67504&#xD;
 - Chat notebook tutorial: https://reference.wolfram.com/language/tutorial/ChatNotebooks.html&#xD;
 - LLM Functions: https://reference.wolfram.com/language/guide/LLMFunctions.html&#xD;
 - Stephen Wolfram&amp;#039;s blog announcement: https://wolfr.am/NotebookAssistant&#xD;
&#xD;
&#xD;
  [1]: https://www.wolfram.com/notebook-assistant-llm-kit/&#xD;
  [2]: https://community.wolfram.com//c/portal/getImageAttachment?filename=Example2.png&amp;amp;userId=462781&#xD;
  [3]: https://reference.wolfram.com/language/tutorial/ChatNotebooks.html&#xD;
  [4]: https://reference.wolfram.com/language/guide/LLMFunctions.html</description>
    <dc:creator>Bradley Ashby</dc:creator>
    <dc:date>2024-12-09T20:51:01Z</dc:date>
  </item>
  <item rdf:about="https://community.wolfram.com/groups/-/m/t/3062832">
    <title>The Telephone Game - next level with GPT</title>
    <link>https://community.wolfram.com/groups/-/m/t/3062832</link>
    <description>![enter image description here][1]&#xD;
&#xD;
&amp;amp;[Wolfram Notebook][2]&#xD;
&#xD;
&#xD;
  [1]: https://community.wolfram.com//c/portal/getImageAttachment?filename=w5qgsdf.jpg&amp;amp;userId=11733&#xD;
  [2]: https://www.wolframcloud.com/obj/04458d24-aacf-4cd7-8a5d-46efde37e927</description>
    <dc:creator>Marco Thiel</dc:creator>
    <dc:date>2023-11-09T22:51:38Z</dc:date>
  </item>
  <item rdf:about="https://community.wolfram.com/groups/-/m/t/884348">
    <title>[WSS16] Image Colorization</title>
    <link>https://community.wolfram.com/groups/-/m/t/884348</link>
    <description>The aim of my project for the Wolfram Science Summer School was to build a neural network which could be able to colorize grayscale images in a realistic way. The network has been built following the article [1]. In this paper, the authors propose a fully automated approach for colorization of grayscale images, which uses a combination of global image features, which are extracted from the entire image, and local image features, which are computed from small image patches. Global priors provide information at an image level such as whether or not the image was taken indoors or outdoors, whether it is day or night, etc., while local features represent the local texture or object at a given location. By combining both features, it&amp;#039;s possible to leverage the semantic information to color the images without requiring human interaction. The approach is based on Convolutional Neural Networks, which have a strong capacity for learning and is trained to predict the chrominance of a grayscale image using the CIE L*a*b* colorspace. Predicting colors has the nice property that training data is practically free: any color photo can be used as a training example. &#xD;
&#xD;
**Net Layers**&#xD;
&#xD;
The model consists of four main components: a low-level features network, a mid-level features network, a global features network, and a colorization network. First, a common set of shared low-level features are extracted from the image. Using these features, a set of global image features and mid-level image features are computed. Then, the mid-level and the global features are both fused by a &amp;#034;fusion layer&amp;#034; and used as the input to a colorization network that outputs the final chrominance map. &#xD;
Each layer has a ReLu transfer function except for the last convolution of the colorization network, where a sigmoid function is applied.The model is able to process images of any size, but it is most efficient when the input images are 224x224 pixels, as the shared low-level features layers can share outputs. Note that when the input image size is of a different resolution, while the low-level feature weights are shared, a rescaled image of size 224x224 must be used for the global features network.This requires processing both the original image and the rescaled image through the low-level features network, increasing both memory consumption and computation time. For this reason, we trained&#xD;
the model exclusively with images of size 224x224 pixels.&#xD;
&#xD;
*Low-Level Features Network*&#xD;
&#xD;
A 6-layer Convolutional Neural Network obtains low-level features directly from the input image. The convolution filter bank the network represents are shared to feed both the global features network and the mid-level features network. In order to reduce the size of the feature maps, we use convolution layers with increased strides instead of using max-pooling layers (as usual for similar kinds of networks). If padding is added to the layer, the output is effectively half the size of the input layer. We used 3x3 convolution kernels exclusively and a padding of 1x1 to ensure the output is the same size (or half if using a stride of 2) as the input.&#xD;
&#xD;
*Global Features Network*&#xD;
&#xD;
The global image features are obtained by further processing the low-level features with four convolutional layers followed by three fully-connected layers.This results in a 256-dimensional vector representation of the image.&#xD;
&#xD;
*Mid-Level Features Network*&#xD;
&#xD;
The mid-level features are obtained by processing the low-level features further with two convolutional layers. The output is bottlenecked from the original 512-channel low-level features to 256-channel mid-level features. Unlike the global image features, the low-level and mid-level features networks are fully convolutional networks, such that the output is a scaled version of the input.&#xD;
&#xD;
*Fusion Layer*&#xD;
&#xD;
In order to be able to combine the global image features, a 256-dimensional vector, with the (mid-level) local image features, a 28x28x256-dimensional tensor, the authors introduce a fusion layer. This can be thought of as concatenating the global features with the local features at each spatial location and processing them through a small one-layer network.This effectively combines the global feature and the local features to obtain a new feature map that is, as the mid-level features, a 3D volume.&#xD;
&#xD;
*Colorization Network*&#xD;
&#xD;
Once the features are fused, they are processed by a set of convolutions and upsampling layers, which use the nearest neighbour technique so that the output is twice as wide and twice as tall. These layers are alternated until the output is half the size of the original input. The&#xD;
output layer of the colorization network consists of a convolutional layer with a Sigmoid transfer function that outputs the chrominance of the input grayscale image. Finally, the computed chrominance is upsampled and combined with the input intensity/luminance image to produce the resulting color image. In order to train the network, we used the Mean Square Error (MSE) criterion. Given a color image for training, the input of the model is the grayscale image while the target output is the a*b* components of the CIE L*a*b* colorspace. The a*b* components are globally normalized so they lie in the [0,1] range of the Sigmoid transfer function. &#xD;
&#xD;
*Colorization with Classification*&#xD;
&#xD;
While training with only color images using the MSE criterion does give good performance, sometimes it could make obvious mistakes due to not properly learning the global context of the image, e.g., whether it is indoors or outdoors. As learning these networks is an non-convex&#xD;
problem, we facilitated the optimization by also training for classification jointly with the colorization. As we trained the model using a large-scale dataset for classification of N classes (Mathematica ImageIdentify dataset), we had classification labels available for training. These labels correspond to a global image tag and thus can be used to guide the training of the global image features. We did this by introducing another very small neural network that consists of two fully-connected layers: a hidden layer with 256 outputs and an output layer with as many outputs as the number of classes in the dataset. The input of this network is the second to last layer of the global features network with 512 outputs. We trained this network using the cross-entropy loss, jointly with the MSE loss for the colorization network.&#xD;
&#xD;
*Implementation*&#xD;
&#xD;
The aim of my project was to build the network described in the paper using the new NeuralNetworks framework of Mathematica 11. In order to achieve this, some adjustments were needed. &#xD;
First of all, we decided to train and evaluate the network only on images of 224x224 pixels size, in order to use (and train) only one low-level features network, instead of two with shared weights and different outputs.&#xD;
The final network has two inputs: the first one is the colored 224x224 px image, encoded by the &amp;#034;NetEncoder&amp;#034; function in LAB colorspace, the second one the class of the image. The two outputs (named &amp;#034;Loss&amp;#034; and &amp;#034;Output&amp;#034;) represent the values of the two loss function used (one for the colorization, the other one for the classification), which are then summed together by the NetTrain function. The three color channels of the input image are split by the split layer: the L channel feeds the &amp;#034;low-level features&amp;#034; network, while the a,b channels are scaled and concatenated in order to obtain a target set for the mean squared loss function comparable with the output of the colorization network. The fusion layer has been replaced by a broadcast layer, which joins the rank 3- tensor, output of the mid-level network, with the vector from the global features network. However, the way they are combined is not exactly the same as the one described in the paper. To evaluate the trained network on a grayscale image it&amp;#039;s necessary to drop some branches of the network, such as the classification network and the layers that process the a,b channels of the colored input image in order to produce the target set for the colorization loss function. &#xD;
&#xD;
![Network described in the paper][1]&#xD;
![Network implementation with Mathematica NeuralNetworks framework][2]&#xD;
&#xD;
**Results**&#xD;
&#xD;
![enter image description here][3]&#xD;
&#xD;
**Conclusions**&#xD;
&#xD;
The network described in the paper has been trained on the Places scene dataset [Zhou et al. 2014], which consists of 2,448,872 training images and 20,500 validation images, with 205 classes corresponding to the types of the scene. They filtered the images by removing grayscale images and those that have little color variance with a small automated script. They trained using a batch size of 128 for 200,000 iterations corresponding to roughly 11 epochs. This takes roughly 3 weeks on one core of a NVIDIAR TeslaR K80 GPU. &#xD;
We needed to introduce some new layers in the existing framework and to fix some bugs, so we were able to train our network only for 14 hours on a dataset of 350000 images on one core of a GPU Titan machine. Furthermore, the images in our training set mainly represent specific items, so probably better results may be achieved introducing also images of different types of subjects (landscapes, human created images, indoors, etc). The results we obtained are showed in the section above and are quite good. We are confident that with a deeper and longer training our network would give considerably better results.&#xD;
&#xD;
**Open Problems / Future Developments**&#xD;
&#xD;
Due to the separation between the global and local features, it is possible to use global features computed on one image in combination with local features computed on another image, to change the style of the resulting colorization. One of the more interesting things the model can do is adapting the colorization of one image to the style of another. This is straight-forward to do with this model due to the decorrelation between the global features and the mid-level features. In order to colorize an image A using the style taken from an image B, it&amp;#039;s necessary to compute the mid-level local features of image A and the global features from image B. Than it&amp;#039;s possible to fuse these features and process them with the colorization network. Both the local and the global features are computed from grayscale images: it&amp;#039;s not necessary to use any color&#xD;
information at all.&#xD;
&#xD;
The main limitation of the method lies in the fact that it is datadriven and thus will only be able to colorize images that share common properties with those in the training set. In order to evaluate on significantly different types of images, it would be necessary to train a&#xD;
the model for all type of images (indoor, outdoor, human-created...). In order to obtain good style transfer results, it is important for both images to have some semantic level of similarity between them.&#xD;
&#xD;
**References**&#xD;
&#xD;
[1] Satoshi Iizuka, Edgar Simo - Serra, and Hiroshi Ishikawa.&amp;#034;Let there be Color!: Joint End-to-end Learning of Global and Local Image Priors for Automatic Image Colorization with Simultaneous Classification&amp;#034;.&#xD;
&#xD;
&#xD;
  [1]: http://community.wolfram.com//c/portal/getImageAttachment?filename=netwPicture.png&amp;amp;userId=884315&#xD;
  [2]: http://community.wolfram.com//c/portal/getImageAttachment?filename=MyNetwork.png&amp;amp;userId=884315&#xD;
  [3]: http://community.wolfram.com//c/portal/getImageAttachment?filename=result2.png&amp;amp;userId=884315</description>
    <dc:creator>Sabrina Giollo</dc:creator>
    <dc:date>2016-07-07T19:53:19Z</dc:date>
  </item>
  <item rdf:about="https://community.wolfram.com/groups/-/m/t/1787163">
    <title>Converting OpenPose for Wolfram Language</title>
    <link>https://community.wolfram.com/groups/-/m/t/1787163</link>
    <description>Tuseeta-san&amp;#039;s [post][1] is how to convert a trained model of TensorFlow to Mathematica. Converting trained models from a language other than Mathematica to Mathematica is very beneficial to Mathematica users. So I&amp;#039;ll show how to convert a trained model of PyTorch to Mathematica along with Tuseeta-san&amp;#039;s post. &#xD;
![enter image description here][2]&#xD;
## Step 1: Figure out the architecture ##&#xD;
The [model][3] to be converted is Pose Estimation that detects the human skeleton (body parts and their connections) from an image. It&amp;#039;s called OpenPose.The model consists of Feature map that extracts image features and six Stage maps.&#xD;
Feature map extracts image features from an input image(size:368*368). Each  Stage map has two-branch, the first branch predicts confidence and the second predicts PAFs?Part Affinity Fields), along with the image feature .Two-branch are concatenated for next stage.&#xD;
## Step 2: Coding it in Mathematica ##&#xD;
**Feature map**&#xD;
&#xD;
The Feature map consists of the first 23 layers of VGG-19, followed by 2 sets of Convolution and Ramp.&#xD;
&#xD;
Extract the first 23 layers of VGG-19.&#xD;
&#xD;
    vgg19 = NetModel[&amp;#034;VGG-19 Trained on ImageNet Competition Data&amp;#034;];&#xD;
    vgg19sub = Take[vgg19, {1, 23}];&#xD;
&#xD;
Change Encoder.&#xD;
&#xD;
    enc = NetExtract[vgg19, &amp;#034;Input&amp;#034;];&#xD;
    enc = NetReplacePart[&#xD;
       enc, {&amp;#034;ImageSize&amp;#034; -&amp;gt; {368, 368}, &#xD;
        &amp;#034;VarianceImage&amp;#034; -&amp;gt; {0.229, 0.224, 0.225}, &#xD;
        &amp;#034;MeanImage&amp;#034; -&amp;gt; {0.485, 0.456, 0.406}}];&#xD;
    featurefirst = NetReplacePart[vgg19sub, &amp;#034;Input&amp;#034; -&amp;gt; enc];&#xD;
&#xD;
Add Convolution and Ramp.&#xD;
&#xD;
    feature = &#xD;
      NetAppend[&#xD;
       featurefirst, {&amp;#034;convadd1&amp;#034; -&amp;gt; &#xD;
         ConvolutionLayer[256, 3, &amp;#034;Stride&amp;#034; -&amp;gt; 1, &amp;#034;PaddingSize&amp;#034; -&amp;gt; 1], &#xD;
        &amp;#034;reluadd1&amp;#034; -&amp;gt; Ramp,&#xD;
        &amp;#034;convadd2&amp;#034; -&amp;gt; &#xD;
         ConvolutionLayer[128, 3, &amp;#034;Stride&amp;#034; -&amp;gt; 1, &amp;#034;PaddingSize&amp;#034; -&amp;gt; 1], &#xD;
        &amp;#034;reluadd2&amp;#034; -&amp;gt; Ramp}];&#xD;
&#xD;
**Stage map**&#xD;
&#xD;
Each Stage map consists only of Convolutions and Ramps.&#xD;
&#xD;
Stage 1: The differences between two branches is that the last output channel number is 38 or 19.&#xD;
&#xD;
    blk11 = NetChain[{&#xD;
        ConvolutionLayer[128, 3, &amp;#034;Stride&amp;#034; -&amp;gt; 1, &amp;#034;PaddingSize&amp;#034; -&amp;gt; 1], Ramp,&#xD;
        ConvolutionLayer[128, 3, &amp;#034;Stride&amp;#034; -&amp;gt; 1, &amp;#034;PaddingSize&amp;#034; -&amp;gt; 1], Ramp,&#xD;
        ConvolutionLayer[128, 3, &amp;#034;Stride&amp;#034; -&amp;gt; 1, &amp;#034;PaddingSize&amp;#034; -&amp;gt; 1], Ramp,&#xD;
        ConvolutionLayer[512, 1, &amp;#034;Stride&amp;#034; -&amp;gt; 1, &amp;#034;PaddingSize&amp;#034; -&amp;gt; 0], Ramp,&#xD;
        ConvolutionLayer[38, 1, &amp;#034;Stride&amp;#034; -&amp;gt; 1, &amp;#034;PaddingSize&amp;#034; -&amp;gt; 0]}];&#xD;
    blk12 = NetChain[{&#xD;
        ConvolutionLayer[128, 3, &amp;#034;Stride&amp;#034; -&amp;gt; 1, &amp;#034;PaddingSize&amp;#034; -&amp;gt; 1], Ramp,&#xD;
        ConvolutionLayer[128, 3, &amp;#034;Stride&amp;#034; -&amp;gt; 1, &amp;#034;PaddingSize&amp;#034; -&amp;gt; 1], Ramp,&#xD;
        ConvolutionLayer[128, 3, &amp;#034;Stride&amp;#034; -&amp;gt; 1, &amp;#034;PaddingSize&amp;#034; -&amp;gt; 1], Ramp,&#xD;
        ConvolutionLayer[512, 1, &amp;#034;Stride&amp;#034; -&amp;gt; 1, &amp;#034;PaddingSize&amp;#034; -&amp;gt; 0], Ramp,&#xD;
        ConvolutionLayer[19, 1, &amp;#034;Stride&amp;#034; -&amp;gt; 1, &amp;#034;PaddingSize&amp;#034; -&amp;gt; 0]}];&#xD;
&#xD;
Stage 2?6: The difference between Stage1 and Stage2?6 is the kinds and the numbers of layers.&#xD;
&#xD;
    blkx1 = NetChain[{&#xD;
        ConvolutionLayer[128, 7, &amp;#034;Stride&amp;#034; -&amp;gt; 1, &amp;#034;PaddingSize&amp;#034; -&amp;gt; 3], Ramp,&#xD;
        ConvolutionLayer[128, 7, &amp;#034;Stride&amp;#034; -&amp;gt; 1, &amp;#034;PaddingSize&amp;#034; -&amp;gt; 3], Ramp,&#xD;
        ConvolutionLayer[128, 7, &amp;#034;Stride&amp;#034; -&amp;gt; 1, &amp;#034;PaddingSize&amp;#034; -&amp;gt; 3], Ramp,&#xD;
        ConvolutionLayer[128, 7, &amp;#034;Stride&amp;#034; -&amp;gt; 1, &amp;#034;PaddingSize&amp;#034; -&amp;gt; 3], Ramp,&#xD;
        ConvolutionLayer[128, 7, &amp;#034;Stride&amp;#034; -&amp;gt; 1, &amp;#034;PaddingSize&amp;#034; -&amp;gt; 3], Ramp,&#xD;
        ConvolutionLayer[128, 1, &amp;#034;Stride&amp;#034; -&amp;gt; 1, &amp;#034;PaddingSize&amp;#034; -&amp;gt; 0], Ramp,&#xD;
        ConvolutionLayer[38, 1, &amp;#034;Stride&amp;#034; -&amp;gt; 1, &amp;#034;PaddingSize&amp;#034; -&amp;gt; 0]}];&#xD;
    blkx2 = NetChain[{&#xD;
        ConvolutionLayer[128, 7, &amp;#034;Stride&amp;#034; -&amp;gt; 1, &amp;#034;PaddingSize&amp;#034; -&amp;gt; 3], Ramp,&#xD;
        ConvolutionLayer[128, 7, &amp;#034;Stride&amp;#034; -&amp;gt; 1, &amp;#034;PaddingSize&amp;#034; -&amp;gt; 3], Ramp,&#xD;
        ConvolutionLayer[128, 7, &amp;#034;Stride&amp;#034; -&amp;gt; 1, &amp;#034;PaddingSize&amp;#034; -&amp;gt; 3], Ramp,&#xD;
        ConvolutionLayer[128, 7, &amp;#034;Stride&amp;#034; -&amp;gt; 1, &amp;#034;PaddingSize&amp;#034; -&amp;gt; 3], Ramp,&#xD;
        ConvolutionLayer[128, 7, &amp;#034;Stride&amp;#034; -&amp;gt; 1, &amp;#034;PaddingSize&amp;#034; -&amp;gt; 3], Ramp,&#xD;
        ConvolutionLayer[128, 1, &amp;#034;Stride&amp;#034; -&amp;gt; 1, &amp;#034;PaddingSize&amp;#034; -&amp;gt; 0], Ramp,&#xD;
        ConvolutionLayer[19, 1, &amp;#034;Stride&amp;#034; -&amp;gt; 1, &amp;#034;PaddingSize&amp;#034; -&amp;gt; 0]}];&#xD;
&#xD;
Finally, create OpenPose.&#xD;
&#xD;
    openpose = NetGraph[{&#xD;
       &amp;#034;feature&amp;#034; -&amp;gt; feature,(*feature*)&#xD;
       &amp;#034;blk11&amp;#034; -&amp;gt; blk11, &amp;#034;blk12&amp;#034; -&amp;gt; blk12,(*stage 1*)&#xD;
       &amp;#034;blk21&amp;#034; -&amp;gt; blkx1, &amp;#034;blk22&amp;#034; -&amp;gt; blkx2,(*stage 2*)&#xD;
       &amp;#034;cat12&amp;#034; -&amp;gt; CatenateLayer[],&#xD;
       &amp;#034;blk31&amp;#034; -&amp;gt; blkx1, &amp;#034;blk32&amp;#034; -&amp;gt; blkx2,(*stage 3*)&#xD;
       &amp;#034;cat23&amp;#034; -&amp;gt; CatenateLayer[],&#xD;
       &amp;#034;blk41&amp;#034; -&amp;gt; blkx1, &amp;#034;blk42&amp;#034; -&amp;gt; blkx2,(*stage 4*)&#xD;
       &amp;#034;cat34&amp;#034; -&amp;gt; CatenateLayer[],&#xD;
       &amp;#034;blk51&amp;#034; -&amp;gt; blkx1, &amp;#034;blk52&amp;#034; -&amp;gt; blkx2,(*stage 5*)&#xD;
       &amp;#034;cat45&amp;#034; -&amp;gt; CatenateLayer[],&#xD;
       &amp;#034;blk61&amp;#034; -&amp;gt; blkx1, &amp;#034;blk62&amp;#034; -&amp;gt; blkx2,(*stage 6*)&#xD;
       &amp;#034;cat56&amp;#034; -&amp;gt; CatenateLayer[]&#xD;
       },&#xD;
      {&amp;#034;feature&amp;#034; -&amp;gt; &amp;#034;blk11&amp;#034;, &amp;#034;feature&amp;#034; -&amp;gt; &amp;#034;blk12&amp;#034;,(*stage 1*)&#xD;
       {&amp;#034;blk11&amp;#034;, &amp;#034;blk12&amp;#034;, &amp;#034;feature&amp;#034;} -&amp;gt; &amp;#034;cat12&amp;#034;,(*stage 2*)&#xD;
       &amp;#034;cat12&amp;#034; -&amp;gt; &amp;#034;blk21&amp;#034;, &amp;#034;cat12&amp;#034; -&amp;gt; &amp;#034;blk22&amp;#034;,&#xD;
       {&amp;#034;blk21&amp;#034;, &amp;#034;blk22&amp;#034;, &amp;#034;feature&amp;#034;} -&amp;gt; &amp;#034;cat23&amp;#034;,(*stage 3*)&#xD;
       &amp;#034;cat23&amp;#034; -&amp;gt; &amp;#034;blk31&amp;#034;, &amp;#034;cat23&amp;#034; -&amp;gt; &amp;#034;blk32&amp;#034;,&#xD;
       {&amp;#034;blk31&amp;#034;, &amp;#034;blk32&amp;#034;, &amp;#034;feature&amp;#034;} -&amp;gt; &amp;#034;cat34&amp;#034;,(*stage 4*)&#xD;
       &amp;#034;cat34&amp;#034; -&amp;gt; &amp;#034;blk41&amp;#034;, &amp;#034;cat34&amp;#034; -&amp;gt; &amp;#034;blk42&amp;#034;,&#xD;
       {&amp;#034;blk41&amp;#034;, &amp;#034;blk42&amp;#034;, &amp;#034;feature&amp;#034;} -&amp;gt; &amp;#034;cat45&amp;#034;,(*stage 5*)&#xD;
       &amp;#034;cat45&amp;#034; -&amp;gt; &amp;#034;blk51&amp;#034;, &amp;#034;cat45&amp;#034; -&amp;gt; &amp;#034;blk52&amp;#034;,&#xD;
       {&amp;#034;blk51&amp;#034;, &amp;#034;blk52&amp;#034;, &amp;#034;feature&amp;#034;} -&amp;gt; &amp;#034;cat56&amp;#034;,(*stage 6*)&#xD;
       &amp;#034;cat56&amp;#034; -&amp;gt; &amp;#034;blk61&amp;#034;, &amp;#034;cat56&amp;#034; -&amp;gt; &amp;#034;blk62&amp;#034;&#xD;
       }]&#xD;
  &#xD;
![enter image description here][4]&#xD;
&#xD;
## Step 3: Importing the Weights and the Biases ##&#xD;
Download &amp;#034;[pose_model_scratch.pth][5]&amp;#034; as a trained model of PyTorch.&#xD;
&#xD;
Import the parameters, the weights and the biases. I referred &amp;#034;[How to import python pickle *.pkl?][6]&amp;#034;&#xD;
&#xD;
    session = StartExternalSession[&amp;#034;Python-NumPy&amp;#034;];&#xD;
    parameters = ExternalEvaluate[session, &amp;#034;import torch&#xD;
    import numpy as np&#xD;
    import pickle as pkl&#xD;
       &#xD;
    net_weights = torch.load(&#xD;
           &amp;#039;pose_model_scratch.pth&amp;#039;, map_location={&amp;#039;cuda:0&amp;#039;: &amp;#039;cpu&amp;#039;})&#xD;
    keys = list(net_weights.keys())&#xD;
       &#xD;
    parameters = {}&#xD;
    for i in range(len(keys)):&#xD;
           t = net_weights[keys[i]]       &#xD;
           x = t.numpy()&#xD;
           parameters[keys[i]] = x.flatten()&#xD;
    parameters&amp;#034;];&#xD;
    DeleteObject[session];&#xD;
    &#xD;
    keys = Keys[parameters];&#xD;
    parameters = Values[parameters];&#xD;
&#xD;
## Step 4: Parsing the Weights and the Biases ##&#xD;
&#xD;
The parameters is 184 sets of one-dimensional lists. They consists of the Weights and the Biases of 92 Convolution layers in OpenPose.&#xD;
&#xD;
Get a list of layer names for OpenPose with depth level. Then, get a list of 92 names where convolution layer is used in it.&#xD;
&#xD;
    layernames = &#xD;
      GroupBy[Keys@NetInformation[openpose, &amp;#034;Layers&amp;#034;], First] // Values;&#xD;
    convlayernames = (Position[&#xD;
         NetInformation[openpose, &amp;#034;Layers&amp;#034;], _ConvolutionLayer] // &#xD;
        Flatten)[[All, 1]]&#xD;
&#xD;
![enter image description here][7]&#xD;
&#xD;
As you can see in keys, you can see that the order of convolution layers of OpenPose is different from the order of convolution layers of &amp;#034;pose_model_scratch.pth&amp;#034; &#xD;
&#xD;
     keys&#xD;
&#xD;
![enter image description here][8]&#xD;
&#xD;
So, manually sort   the order of convolution layers in OpenPose into the order of &amp;#034;pose_model_scratch.pth&amp;#034;&#xD;
&#xD;
    convlayernamesGH = {{&amp;#034;feature&amp;#034;, &amp;#034;conv1_1&amp;#034;}, {&amp;#034;feature&amp;#034;, &amp;#034;conv1_2&amp;#034;},&#xD;
       {&amp;#034;feature&amp;#034;, &amp;#034;conv2_1&amp;#034;}, {&amp;#034;feature&amp;#034;, &amp;#034;conv2_2&amp;#034;},&#xD;
       {&amp;#034;feature&amp;#034;, &amp;#034;conv3_1&amp;#034;}, {&amp;#034;feature&amp;#034;, &amp;#034;conv3_2&amp;#034;}, {&amp;#034;feature&amp;#034;, &amp;#034;conv3_3&amp;#034;}, {&amp;#034;feature&amp;#034;, &amp;#034;conv3_4&amp;#034;},&#xD;
       {&amp;#034;feature&amp;#034;, &amp;#034;conv4_1&amp;#034;}, {&amp;#034;feature&amp;#034;, &amp;#034;conv4_2&amp;#034;},&#xD;
       {&amp;#034;feature&amp;#034;, &amp;#034;convadd1&amp;#034;}, {&amp;#034;feature&amp;#034;, &amp;#034;convadd2&amp;#034;},&#xD;
       {&amp;#034;blk11&amp;#034;, 1}, {&amp;#034;blk11&amp;#034;, 3}, {&amp;#034;blk11&amp;#034;, 5}, {&amp;#034;blk11&amp;#034;, 7}, {&amp;#034;blk11&amp;#034;, 9},&#xD;
       {&amp;#034;blk21&amp;#034;, 1}, {&amp;#034;blk21&amp;#034;, 3}, {&amp;#034;blk21&amp;#034;, 5}, {&amp;#034;blk21&amp;#034;, 7}, {&amp;#034;blk21&amp;#034;, 9}, {&amp;#034;blk21&amp;#034;, 11}, {&amp;#034;blk21&amp;#034;, 13},&#xD;
       {&amp;#034;blk31&amp;#034;, 1}, {&amp;#034;blk31&amp;#034;, 3}, {&amp;#034;blk31&amp;#034;, 5}, {&amp;#034;blk31&amp;#034;, 7}, {&amp;#034;blk31&amp;#034;, 9}, {&amp;#034;blk31&amp;#034;, 11}, {&amp;#034;blk31&amp;#034;, 13},&#xD;
       {&amp;#034;blk41&amp;#034;, 1}, {&amp;#034;blk41&amp;#034;, 3}, {&amp;#034;blk41&amp;#034;, 5}, {&amp;#034;blk41&amp;#034;, 7}, {&amp;#034;blk41&amp;#034;, 9}, {&amp;#034;blk41&amp;#034;, 11}, {&amp;#034;blk41&amp;#034;, 13},&#xD;
       {&amp;#034;blk51&amp;#034;, 1}, {&amp;#034;blk51&amp;#034;, 3}, {&amp;#034;blk51&amp;#034;, 5}, {&amp;#034;blk51&amp;#034;, 7}, {&amp;#034;blk51&amp;#034;, 9}, {&amp;#034;blk51&amp;#034;, 11}, {&amp;#034;blk51&amp;#034;, 13},&#xD;
       {&amp;#034;blk61&amp;#034;, 1}, {&amp;#034;blk61&amp;#034;, 3}, {&amp;#034;blk61&amp;#034;, 5}, {&amp;#034;blk61&amp;#034;, 7}, {&amp;#034;blk61&amp;#034;, 9}, {&amp;#034;blk61&amp;#034;, 11}, {&amp;#034;blk61&amp;#034;, 13},&#xD;
       {&amp;#034;blk12&amp;#034;, 1}, {&amp;#034;blk12&amp;#034;, 3}, {&amp;#034;blk12&amp;#034;, 5}, {&amp;#034;blk12&amp;#034;, 7}, {&amp;#034;blk12&amp;#034;, 9},&#xD;
       {&amp;#034;blk22&amp;#034;, 1}, {&amp;#034;blk22&amp;#034;, 3}, {&amp;#034;blk22&amp;#034;, 5}, {&amp;#034;blk22&amp;#034;, 7}, {&amp;#034;blk22&amp;#034;, 9}, {&amp;#034;blk22&amp;#034;, 11}, {&amp;#034;blk22&amp;#034;, 13},&#xD;
       {&amp;#034;blk32&amp;#034;, 1}, {&amp;#034;blk32&amp;#034;, 3}, {&amp;#034;blk32&amp;#034;, 5}, {&amp;#034;blk32&amp;#034;, 7}, {&amp;#034;blk32&amp;#034;, 9}, {&amp;#034;blk32&amp;#034;, 11}, {&amp;#034;blk32&amp;#034;, 13},&#xD;
       {&amp;#034;blk42&amp;#034;, 1}, {&amp;#034;blk42&amp;#034;, 3}, {&amp;#034;blk42&amp;#034;, 5}, {&amp;#034;blk42&amp;#034;, 7}, {&amp;#034;blk42&amp;#034;, 9}, {&amp;#034;blk42&amp;#034;, 11}, {&amp;#034;blk42&amp;#034;, 13},&#xD;
       {&amp;#034;blk52&amp;#034;, 1}, {&amp;#034;blk52&amp;#034;, 3}, {&amp;#034;blk52&amp;#034;, 5}, {&amp;#034;blk52&amp;#034;, 7}, {&amp;#034;blk52&amp;#034;, 9}, {&amp;#034;blk52&amp;#034;, 11}, {&amp;#034;blk52&amp;#034;, 13},&#xD;
       {&amp;#034;blk62&amp;#034;, 1}, {&amp;#034;blk62&amp;#034;, 3}, {&amp;#034;blk62&amp;#034;, 5}, {&amp;#034;blk62&amp;#034;, 7}, {&amp;#034;blk62&amp;#034;, 9}, {&amp;#034;blk62&amp;#034;, 11}, {&amp;#034;blk62&amp;#034;, 13}&#xD;
       };&#xD;
&#xD;
Get the position of each element of convlayernamesGH in OpenPose.&#xD;
&#xD;
    convlayerpos = &#xD;
     Flatten[Position[layernames, #] &amp;amp; /@ convlayernamesGH, 1]&#xD;
&#xD;
![enter image description here][9]&#xD;
&#xD;
Reshape each one-dimensional list of parameters to the dimension of the corresponding weight or bias.&#xD;
&#xD;
    getDimB[layer_] := Dimensions@NetExtract[layer, &amp;#034;Biases&amp;#034;]&#xD;
    getDimW[layer_] := Dimensions@NetExtract[layer, &amp;#034;Weights&amp;#034;]&#xD;
    convs = NetExtract[NetInitialize[openpose], #] &amp;amp; /@ convlayerpos;&#xD;
    dimW = getDimW /@ convs;&#xD;
    dimB = getDimB /@ convs;&#xD;
    dim = Flatten[Transpose[{dimW, dimB}], 1];&#xD;
    parametersReshape = MapThread[ArrayReshape, {parameters, dim}];&#xD;
&#xD;
## Step 5: Linking the Weights and the Biases ##&#xD;
Replace the initial values of weights and biases in OpenPose with learned parameters, and finally get trained OpenPose.&#xD;
&#xD;
    replacenames =&#xD;
      Flatten[&#xD;
       Transpose[{Flatten@{#, &amp;#034;Weights&amp;#034;} &amp;amp; /@ convlayernamesGH, &#xD;
         Flatten@{#, &amp;#034;Biases&amp;#034;} &amp;amp; /@ convlayernamesGH}], 1];&#xD;
    rule = Thread[replacenames -&amp;gt; parametersReshape];&#xD;
    trainedOpenPose = NetReplacePart[openpose, rule]&#xD;
&#xD;
![enter image description here][10]&#xD;
&#xD;
## Step 6: Making the tests ##&#xD;
For simplification, estimate pose for the image of single-person. The Output2 of OpenPose shows the confidence of 19 body parts in each part where the image is divided into 46 * 46.&#xD;
&#xD;
1:Nose, 2:Neck, 3:RShoulder, 4:RElbow, 5:RWrist, 6:LShoulder, 7:LElbow, 8:LWrist,&#xD;
9:RHip, 10:RKnee, 11:RAnkle, 12:LHip, 13:LKnee, 14:LAnkle, 15:REye, 16:LEye, 17:REar, 18:LEar, 19:Bkg&#xD;
&#xD;
Define the function to get the position of max of confidence of each body part.&#xD;
&#xD;
    maxpts[img_, confidences_, idex_] := Module[{pos, pts, h},&#xD;
      pos = Reverse@First@Position[h = confidences[[idex]], Max@h];&#xD;
      pts = (pos/46)*ImageDimensions@img; &#xD;
      pts = {pts[[1]], (ImageDimensions@img)[[2]] - pts[[2]]}&#xD;
      ]&#xD;
&#xD;
Connect the detected body parts and show the result together on the original image.&#xD;
&#xD;
    showpose[img_] := Module[{bodylist, size, out, confidences, pts, pose},&#xD;
      bodylist = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14};&#xD;
      size = {368, 368};&#xD;
      out = trainedOpenPose[img];&#xD;
      confidences = out[[2]];&#xD;
      pts = maxpts[img, confidences, #] &amp;amp; /@ bodylist;&#xD;
      pose = Graphics[{&#xD;
         Yellow, Thickness[.0125], Line[pts[[#]] &amp;amp; /@ {1, 2}],&#xD;
         Green, Line[pts[[#]] &amp;amp; /@ {2, 3, 4, 5}],&#xD;
         Cyan, Line[pts[[#]] &amp;amp; /@ {2, 6, 7, 8}],&#xD;
         Orange, Line[pts[[#]] &amp;amp; /@ {2, 9, 10, 11}],&#xD;
         Magenta, Line[pts[[#]] &amp;amp; /@ {2, 12, 13, 14}],&#xD;
         PointSize[Large], Red, Point[pts],&#xD;
         White, Point[{{0, 0}, ImageDimensions@img}]&#xD;
         }, ImagePadding -&amp;gt; All];&#xD;
      Show[img, pose]&#xD;
      ]&#xD;
&#xD;
Let&amp;#039; try.&#xD;
&#xD;
    img = Import[&amp;#034;ichiro.jpg&amp;#034;];&#xD;
    showpose[img]&#xD;
&#xD;
![enter image description here][11]&#xD;
&#xD;
## Future work ##&#xD;
? Estimate the pose of an image in which multi-person are by using PAFs of output1 of OpenPose.&#xD;
&#xD;
? Convert a more accurate pose estimation model.&#xD;
&#xD;
&#xD;
  [1]: https://community.wolfram.com/groups/-/m/t/1785523&#xD;
  [2]: https://community.wolfram.com//c/portal/getImageAttachment?filename=00.jpg&amp;amp;userId=1013863&#xD;
  [3]: https://arxiv.org/pdf/1611.08050.pdf&#xD;
  [4]: https://community.wolfram.com//c/portal/getImageAttachment?filename=752004.jpg&amp;amp;userId=1013863&#xD;
  [5]: https://www.dropbox.com/s/ae071mfm2qoyc8v/pose_model.pth?dl=0&#xD;
  [6]: https://mathematica.stackexchange.com/questions/181273/how-to-import-%5C%20python-pickle-pkl?rq=1&#xD;
  [7]: https://community.wolfram.com//c/portal/getImageAttachment?filename=691905.jpg&amp;amp;userId=1013863&#xD;
  [8]: https://community.wolfram.com//c/portal/getImageAttachment?filename=387908.jpg&amp;amp;userId=1013863&#xD;
  [9]: https://community.wolfram.com//c/portal/getImageAttachment?filename=109406.jpg&amp;amp;userId=1013863&#xD;
  [10]: https://community.wolfram.com//c/portal/getImageAttachment?filename=179107.jpg&amp;amp;userId=1013863&#xD;
  [11]: https://community.wolfram.com//c/portal/getImageAttachment?filename=161401.jpg&amp;amp;userId=1013863</description>
    <dc:creator>Kotaro Okazaki</dc:creator>
    <dc:date>2019-09-10T21:36:49Z</dc:date>
  </item>
  <item rdf:about="https://community.wolfram.com/groups/-/m/t/3062403">
    <title>Direct API access to new features of GPT-4 (including vision, DALL-E, and TTS)</title>
    <link>https://community.wolfram.com/groups/-/m/t/3062403</link>
    <description>![enter image description here][1]&#xD;
&#xD;
&amp;amp;[Wolfram Notebook][2]&#xD;
&#xD;
&#xD;
  [1]: https://community.wolfram.com//c/portal/getImageAttachment?filename=fg45qw.jpg&amp;amp;userId=11733&#xD;
  [2]: https://www.wolframcloud.com/obj/34ac42c4-10de-4201-a158-6af47eda2bd8</description>
    <dc:creator>Marco Thiel</dc:creator>
    <dc:date>2023-11-08T21:48:25Z</dc:date>
  </item>
  <item rdf:about="https://community.wolfram.com/groups/-/m/t/2166833">
    <title>Predicting COVID-19 using cough sounds classification</title>
    <link>https://community.wolfram.com/groups/-/m/t/2166833</link>
    <description>&amp;amp;[Wolfram Notebook][1]&#xD;
&#xD;
&#xD;
  [1]: https://www.wolframcloud.com/obj/cdf7d474-f4fb-4cbd-bbd5-f1fac8699f7a</description>
    <dc:creator>Siria Sadeddin</dc:creator>
    <dc:date>2021-01-18T22:46:11Z</dc:date>
  </item>
  <item rdf:about="https://community.wolfram.com/groups/-/m/t/1221098">
    <title>Classifying Japanese characters from the Edo period</title>
    <link>https://community.wolfram.com/groups/-/m/t/1221098</link>
    <description>Introduction&#xD;
----------&#xD;
&#xD;
I recently came across a post for a computer program that in some fields intends to compete with the Wolfram Language and which has a toolbox for Machine Learning. I wanted to compare the work described with the workflow in Mathematica. The challenge is to classify old Japanese Characters from texts from the so-called Edo period:&#xD;
&#xD;
    Style[StringTake[WikipediaData[&amp;#034;Edo period&amp;#034;], 601], 16]&#xD;
&#xD;
![enter image description here][1]&#xD;
&#xD;
The characters are written in running style and apparently are difficult to read for Japanese speakers today. We will use two approaches of machine learning in the Wolfram Language to tackle this problem. &#xD;
&#xD;
Historical Background&#xD;
-----------------------------&#xD;
&#xD;
Before we proceed, let&amp;#039;s have a look at the Tokugawa shogunate. I will use code borrow from [@Vitaliy Kaurov][at0] from his great article on [&amp;#034;Computational history: countries that are gone&amp;#034;][2]. The following lines compute the historic boundaries of the shogunate:&#xD;
&#xD;
    Monitor[tokugawaPOLY = &#xD;
       Table[EntityValue[Entity[&amp;#034;HistoricalCountry&amp;#034;, &amp;#034;TokugawaShogunate&amp;#034;],&#xD;
          EntityProperty[&amp;#034;HistoricalCountry&amp;#034;, &#xD;
          &amp;#034;Polygon&amp;#034;, {&amp;#034;Date&amp;#034; -&amp;gt; DateObject[{t}]}]], {t, 1600, 1870}];, t]&#xD;
&#xD;
We then only filter for &amp;#034;changes&amp;#034; in the boundaries:&#xD;
&#xD;
    tokugawaPOLY // Length&#xD;
    tokugawaPOLYcomp = &#xD;
      DeleteMissing[&#xD;
       DeleteDuplicates[Transpose[{Range[1600, 1870], tokugawaPOLY}], &#xD;
        Last[#1] == Last[#2] &amp;amp;], 1, 2];&#xD;
    tokugawaPOLYcomp // Length&#xD;
&#xD;
In the 271 I consider in the first place there are only 4 changes to the boarders, which we can plot like so:&#xD;
&#xD;
    GeoGraphics[{EdgeForm[Red], GeoStyling[Opacity[.1]], #} &amp;amp; /@ &#xD;
      tokugawaPOLYcomp[[All, 2]], GeoProjection -&amp;gt; &amp;#034;Mercator&amp;#034;, &#xD;
     ImageSize -&amp;gt; 800, GeoBackground -&amp;gt; GeoStyling[&amp;#034;StreetMap&amp;#034;], &#xD;
     GeoRange -&amp;gt; Entity[&amp;#034;Country&amp;#034;, &amp;#034;Japan&amp;#034;], &#xD;
     GeoRangePadding -&amp;gt; Quantity[800, &amp;#034;Kilometers&amp;#034;], GeoZoomLevel -&amp;gt; 6]&#xD;
&#xD;
![enter image description here][3]&#xD;
&#xD;
So the boarders were indeed very stable for a long period reflecting the &amp;#034;no more wars&amp;#034; philosophy of the day.&#xD;
&#xD;
Arts and culture&#xD;
----------&#xD;
&#xD;
 The stability led to a very rich art and literature scene. Here are some images that reflect the style of the time:&#xD;
&#xD;
    ImageCollage[&amp;#034;Thumbnail&amp;#034; /. Normal[Normal[WebImageSearch[&amp;#034;Edo Period&amp;#034;]]], Method -&amp;gt; &amp;#034;Rows&amp;#034;]&#xD;
&#xD;
![enter image description here][4]&#xD;
&#xD;
Our dataset&#xD;
----------&#xD;
&#xD;
Also literature flourished during this period. Our dataset will be taken from the [Center for Open Data in the Humanities][5]. The keen reader might have noticed that the page is in Japanese. Mathematica can translate the page, and [so can Google][6]. The dataset is called the &amp;#034;Japanese classic registered glyph data set&amp;#034;; ?????????????.&#xD;
&#xD;
    TextTranslation[&amp;#034;?????????????&amp;#034;]&#xD;
&#xD;
&amp;#034;Japan classics-type datasets&amp;#034;. Following the first link (grey box) on the original Japanese page one gets to t[his page][7], from the bottom of which (look for a download symbol and the text &amp;#034;(TAR+GZ 24.57 MB)&amp;#034; the dataset can be downloaded. This is the google translation of the reference:&#xD;
&#xD;
&amp;gt; Japanese Classic Statement Character Data Set&amp;#034; (Kokugaku Kenkyu Other&#xD;
&amp;gt; Collection / CODH Processing)&#xD;
&#xD;
which in the original is &amp;#034;???????????????????????CODH??&amp;#034;.&#xD;
&#xD;
The glyphs come from &amp;#034;bamboo letters&amp;#034; from 15 classic texts; the dataset contains more than 20000 glyphs of the 10 most frequent symbols. These letters were annotated by the &amp;#034;National Institute of Letters of Japan&amp;#034; (google). The dataset was also used in a [data/machine learning challenge][8].&#xD;
&#xD;
After extracting the file to a folder on the desktop I can import the images with:&#xD;
&#xD;
    characterImages = Import[&amp;#034;/Users/thiel/Desktop/pmjt_sample_20161116/train_test_file_list.h5&amp;#034;, &amp;#034;Data&amp;#034;];&#xD;
&#xD;
Here is a sample of the glyphs:&#xD;
&#xD;
    Grid[Partition[ImageAdjust[Image[#/256.]] &amp;amp; /@ characterImages[[3, 1 ;; 24]], 6], Frame -&amp;gt; All]&#xD;
&#xD;
![enter image description here][9]&#xD;
&#xD;
Similar to the MNIST dataset, they consist of 28 times 28 pixels. They give the grey level as integers, which is why I divide by 256. This shows the pixelation of the glyphs:&#xD;
&#xD;
    Image[characterImages[[3, 12]]/256.] // ImageAdjust&#xD;
&#xD;
![enter image description here][10]&#xD;
&#xD;
The dataset conveniently contains a training and a test set. There are &#xD;
&#xD;
    characterImages[[3]] // Length&#xD;
&#xD;
19909 glyphs in the training set. All of these are annotated:&#xD;
&#xD;
    Flatten[characterImages[[4]]]&#xD;
&#xD;
![enter image description here][11]&#xD;
&#xD;
We can convert the training data to images like so:&#xD;
&#xD;
Monitor[trainingset = Table[ImageAdjust[Image[characterImages[[3, k]]/256.]] -&amp;gt; Flatten[characterImages[[4]]][[k]], {k, 1, 19909}];, k]&#xD;
&#xD;
The test set contains &#xD;
&#xD;
    characterImages[[1]] // Length&#xD;
&#xD;
3514 glyphs. The annotation of which are found in&#xD;
&#xD;
    characterImages[[2]] // Flatten // Short&#xD;
&#xD;
![enter image description here][12]&#xD;
&#xD;
This is how we prepare the test set data for our machine learning:&#xD;
&#xD;
    Monitor[testset = Table[ImageAdjust[Image[characterImages[[1, k]]/256.]] -&amp;gt; Flatten[characterImages[[2]]][[k]], {k, 1, 3514}];, k]&#xD;
&#xD;
What are the 10 most frequent symbols?&#xD;
----------&#xD;
&#xD;
In one of the annotation files we find the character codes of the symbols so that we can map the classification to actual symbols. These are the glyphs we will consider:&#xD;
&#xD;
    Rasterize /@ (Style[&#xD;
         FromCharacterCode[&#xD;
          ToExpression[&amp;#034;16^^&amp;#034; &amp;lt;&amp;gt; StringJoin[Characters[#]]]], &#xD;
         100] &amp;amp; /@ {&amp;#034;3057&amp;#034;, &amp;#034;306B&amp;#034;, &amp;#034;306E&amp;#034;, &amp;#034;3066&amp;#034;, &amp;#034;308A&amp;#034;, &amp;#034;3092&amp;#034;, &#xD;
        &amp;#034;304B&amp;#034;, &amp;#034;304F&amp;#034;, &amp;#034;304D&amp;#034;, &amp;#034;3082&amp;#034;})&#xD;
&#xD;
![enter image description here][13]&#xD;
&#xD;
We can also make an image collage of them:&#xD;
&#xD;
    ImageCollage[&#xD;
     Image /@ (Rasterize /@ (Style[&#xD;
            FromCharacterCode[&#xD;
             ToExpression[&amp;#034;16^^&amp;#034; &amp;lt;&amp;gt; StringJoin[Characters[#]]]], &#xD;
            100] &amp;amp; /@ {&amp;#034;3057&amp;#034;, &amp;#034;306B&amp;#034;, &amp;#034;306E&amp;#034;, &amp;#034;3066&amp;#034;, &amp;#034;308A&amp;#034;, &amp;#034;3092&amp;#034;, &#xD;
           &amp;#034;304B&amp;#034;, &amp;#034;304F&amp;#034;, &amp;#034;304D&amp;#034;, &amp;#034;3082&amp;#034;})), Method -&amp;gt; &amp;#034;Rows&amp;#034;]&#xD;
&#xD;
![enter image description here][14]&#xD;
&#xD;
I though it would be nice if they were in a more calligraphic form. So I tried to used ImageRestyle to try and make them more calligraphic. I think that the attempt was not very successful, but I want to show it anyway.&#xD;
&#xD;
First I download a couple of calligraphic symbols:&#xD;
&#xD;
    caligraphy = &amp;#034;Thumbnail&amp;#034; /. Normal[Normal[WebImageSearch[&amp;#034;japanese calligraphy&amp;#034;]]]&#xD;
&#xD;
I liked the 5th one, which I will use for the style transfer:&#xD;
&#xD;
    calisymbols = &#xD;
     ImageRestyle[#, caligraphy[[5]], &#xD;
        PerformanceGoal -&amp;gt; &#xD;
         &amp;#034;Quality&amp;#034;] &amp;amp; /@ (Rasterize /@ (Style[&#xD;
            FromCharacterCode[&#xD;
             ToExpression[&amp;#034;16^^&amp;#034; &amp;lt;&amp;gt; StringJoin[Characters[#]]]], &#xD;
            100] &amp;amp; /@ {&amp;#034;3057&amp;#034;, &amp;#034;306B&amp;#034;, &amp;#034;306E&amp;#034;, &amp;#034;3066&amp;#034;, &amp;#034;308A&amp;#034;, &amp;#034;3092&amp;#034;, &#xD;
           &amp;#034;304B&amp;#034;, &amp;#034;304F&amp;#034;, &amp;#034;304D&amp;#034;, &amp;#034;3082&amp;#034;}))&#xD;
&#xD;
![enter image description here][15]&#xD;
&#xD;
We can also remove the background to get an alternative representation:&#xD;
&#xD;
![enter image description here][16]&#xD;
&#xD;
Machine Learning (Classify)&#xD;
----------&#xD;
&#xD;
&#xD;
Our first approach to classify the glyphs will be via Classify. The classification is very fast (only a couple of seconds on my machine) and quite accurate:&#xD;
&#xD;
    standardcl = Classify[trainingset, ValidationSet -&amp;gt; testset, PerformanceGoal -&amp;gt; &amp;#034;Quality&amp;#034;]&#xD;
&#xD;
We can first calculate the ClassifierMeasurements&#xD;
&#xD;
    cmstandard = ClassifierMeasurements[standardcl, testset]&#xD;
&#xD;
and the accuracy:&#xD;
&#xD;
    cmstandard[&amp;#034;Accuracy&amp;#034;]&#xD;
&#xD;
With 92.5% this is quite accurate and also much faster than the competitor product. The confusion plot shows that it is a very reasonable accuracy - in particular when considering that native speakers have problems identifying the glyphs.  &#xD;
&#xD;
    cmstandard[&amp;#034;ConfusionMatrixPlot&amp;#034;]&#xD;
&#xD;
![enter image description here][17]&#xD;
&#xD;
Here are some glyphs that the Classifier identified as class &amp;#034;0&amp;#034;:&#xD;
&#xD;
    cmstandard[&amp;#034;Examples&amp;#034; -&amp;gt; {0, 0}][[1 ;; 20]]&#xD;
&#xD;
![enter image description here][18]&#xD;
&#xD;
They look quite diverse, but so does the original set:&#xD;
&#xD;
    RandomSample[Select[trainingset, #[[2]] == 0 &amp;amp;], 20]&#xD;
&#xD;
![enter image description here][19]&#xD;
&#xD;
It is quite impressive that the Classify function manages to achieve this level of accuracy. We can, however, do better!&#xD;
&#xD;
Machine Learning (NetTrain)&#xD;
----------&#xD;
&#xD;
We can improve the accuracy by training our own custom made network, which in this case will be the standard net that is often used for the MNIST dataset in Mathematica. It turns out that we do not even need a GPU for the training. &#xD;
&#xD;
    lenet = NetChain[{ConvolutionLayer[20, 5], Ramp, PoolingLayer[2, 2], &#xD;
       ConvolutionLayer[50, 5], Ramp, PoolingLayer[2, 2], FlattenLayer[], &#xD;
       500, Ramp, 10, SoftmaxLayer[]}, &#xD;
      &amp;#034;Output&amp;#034; -&amp;gt; NetDecoder[{&amp;#034;Class&amp;#034;, Range[0, 9]}], &#xD;
      &amp;#034;Input&amp;#034; -&amp;gt; NetEncoder[{&amp;#034;Image&amp;#034;, {28, 28}, &amp;#034;Grayscale&amp;#034;}]]&#xD;
&#xD;
![enter image description here][20]&#xD;
&#xD;
This we can then train:&#xD;
&#xD;
    lenet = NetTrain[lenet, trainingset, ValidationSet -&amp;gt; testset, MaxTrainingRounds -&amp;gt; 20];&#xD;
&#xD;
![enter image description here][21]&#xD;
&#xD;
The training is done in about 4:30 minutes, but it appears that 20 training rounds are not necessary. Here are some results when applying the classifier:&#xD;
&#xD;
    imgs = Keys@RandomSample[testset, 60]; Thread[imgs -&amp;gt; lenet[imgs]]&#xD;
&#xD;
![enter image description here][22]&#xD;
&#xD;
Let&amp;#039;s see how well it does:&#xD;
&#xD;
    cm = ClassifierMeasurements[lenet, testset]&#xD;
    cm[&amp;#034;ConfusionMatrixPlot&amp;#034;]&#xD;
&#xD;
![enter image description here][23]&#xD;
&#xD;
This corresponds to an accuracy of &#xD;
&#xD;
    cm[&amp;#034;Accuracy&amp;#034;]&#xD;
&#xD;
95.6%, which is really impressive given the dataset. The following table illustrates the difficulty:&#xD;
&#xD;
    Grid[Table[&#xD;
    Prepend[Select[trainingset, #[[2]] == k &amp;amp;][[1 ;; 10]][[All, 1]], &#xD;
    ImageResize[calisymbols[[k + 1]], 28]], {k, 0, 9}], Frame -&amp;gt; All, &#xD;
    Background -&amp;gt; {{Red}, None}]&#xD;
&#xD;
![enter image description here][24]&#xD;
&#xD;
The first (red) column is derived from the glyph based on the character code - using our &amp;#034;calligraphy-style&amp;#034;. The remaining columns show items from the training set, i.e. glyphs that were manually classified to belong to the given group.&#xD;
&#xD;
Conclusion&#xD;
----------&#xD;
&#xD;
I do not speak/read Japanese and have no more than Wikipedia knowledge about the Edo period. I still find it quite amazing that using the Wolfram Language&amp;#039;s high level Classify function and one of the pre-implemented networks, we can achieve quite a remarkable classification. I am sure that the network can be improved. I would also like to see a more complete dataset with more than 10 different symbols.  &#xD;
&#xD;
&#xD;
 [at0]: http://community.wolfram.com/web/vitaliyk&#xD;
&#xD;
&#xD;
  [1]: http://community.wolfram.com//c/portal/getImageAttachment?filename=ScreenShot2017-11-13at23.24.03.png&amp;amp;userId=48754&#xD;
  [2]: http://community.wolfram.com/groups/-/m/t/852277&#xD;
  [3]: http://community.wolfram.com//c/portal/getImageAttachment?filename=ScreenShot2017-11-13at23.30.18.png&amp;amp;userId=48754&#xD;
  [4]: http://community.wolfram.com//c/portal/getImageAttachment?filename=ScreenShot2017-11-13at23.33.24.png&amp;amp;userId=48754&#xD;
  [5]: http://codh.rois.ac.jp/char-shape/&#xD;
  [6]: https://translate.google.com/translate?hl=en&amp;amp;sl=auto&amp;amp;tl=en&amp;amp;u=http://codh.rois.ac.jp/char-shape/&#xD;
  [7]: http://codh.rois.ac.jp/char-shape/book/&#xD;
  [8]: https://translate.google.com/translate?hl=en&amp;amp;sl=ja&amp;amp;tl=en&amp;amp;u=http://codh.rois.ac.jp/seminar/japanese-character-challenge-20170210/&amp;amp;sandbox=1&#xD;
  [9]: http://community.wolfram.com//c/portal/getImageAttachment?filename=ScreenShot2017-11-13at23.56.19.png&amp;amp;userId=48754&#xD;
  [10]: http://community.wolfram.com//c/portal/getImageAttachment?filename=ScreenShot2017-11-13at23.57.57.png&amp;amp;userId=48754&#xD;
  [11]: http://community.wolfram.com//c/portal/getImageAttachment?filename=ScreenShot2017-11-13at23.59.36.png&amp;amp;userId=48754&#xD;
  [12]: http://community.wolfram.com//c/portal/getImageAttachment?filename=ScreenShot2017-11-14at00.01.19.png&amp;amp;userId=48754&#xD;
  [13]: http://community.wolfram.com//c/portal/getImageAttachment?filename=ScreenShot2017-11-14at00.04.22.png&amp;amp;userId=48754&#xD;
  [14]: http://community.wolfram.com//c/portal/getImageAttachment?filename=ScreenShot2017-11-14at00.05.04.png&amp;amp;userId=48754&#xD;
  [15]: http://community.wolfram.com//c/portal/getImageAttachment?filename=ScreenShot2017-11-14at00.07.44.png&amp;amp;userId=48754&#xD;
  [16]: http://community.wolfram.com//c/portal/getImageAttachment?filename=ScreenShot2017-11-14at00.08.53.png&amp;amp;userId=48754&#xD;
  [17]: http://community.wolfram.com//c/portal/getImageAttachment?filename=ScreenShot2017-11-14at00.15.09.png&amp;amp;userId=48754&#xD;
  [18]: http://community.wolfram.com//c/portal/getImageAttachment?filename=ScreenShot2017-11-14at00.17.07.png&amp;amp;userId=48754&#xD;
  [19]: http://community.wolfram.com//c/portal/getImageAttachment?filename=ScreenShot2017-11-14at00.18.25.png&amp;amp;userId=48754&#xD;
  [20]: http://community.wolfram.com//c/portal/getImageAttachment?filename=ScreenShot2017-11-14at00.21.43.png&amp;amp;userId=48754&#xD;
  [21]: http://community.wolfram.com//c/portal/getImageAttachment?filename=ScreenShot2017-11-14at00.22.50.png&amp;amp;userId=48754&#xD;
  [22]: http://community.wolfram.com//c/portal/getImageAttachment?filename=ScreenShot2017-11-14at00.27.23.png&amp;amp;userId=48754&#xD;
  [23]: http://community.wolfram.com//c/portal/getImageAttachment?filename=ScreenShot2017-11-14at00.28.27.png&amp;amp;userId=48754&#xD;
  [24]: http://community.wolfram.com//c/portal/getImageAttachment?filename=ScreenShot2017-11-14at00.40.41.png&amp;amp;userId=48754</description>
    <dc:creator>Marco Thiel</dc:creator>
    <dc:date>2017-11-14T00:49:30Z</dc:date>
  </item>
  <item rdf:about="https://community.wolfram.com/groups/-/m/t/2864162">
    <title>OpenAIMode: paclet for interaction w/ OpenAI&amp;#039;s GPT &amp;amp; DALL-E via OpenAILink</title>
    <link>https://community.wolfram.com/groups/-/m/t/2864162</link>
    <description>&amp;amp;[Wolfram Notebook][1]&#xD;
&#xD;
&#xD;
  [1]: https://www.wolframcloud.com/obj/04e935d4-d928-4868-adb8-ae6f84fae1f8</description>
    <dc:creator>Anton Antonov</dc:creator>
    <dc:date>2023-04-02T19:01:27Z</dc:date>
  </item>
  <item rdf:about="https://community.wolfram.com/groups/-/m/t/1369571">
    <title>How does a neural network that only knows beauty interpret the world?</title>
    <link>https://community.wolfram.com/groups/-/m/t/1369571</link>
    <description>I recently came across a video that intended to show how neural networks interpret images of (not so beautiful) things if they have only been trained on beautiful things. It is quite a nice question, I think. [Here is a website describing the technique][1], and [here is a video that illustrates the idea][2]. In this post I will show you, how to generate similar effects easily with the Wolfram Language:&#xD;
&#xD;
![enter image description here][3]&#xD;
&#xD;
and in video format:&#xD;
&#xD;
![enter image description here][4]&#xD;
&#xD;
On the right you see the &amp;#034;interpretation&amp;#034; of a neural network that has been shown lots of photos of flowers, when it actually looks at a rubbish dump with a couple of birds sitting on the rubbish. &#xD;
&#xD;
Devising a plan&#xD;
----------&#xD;
&#xD;
We will need a training dataset and should hope to find a network in the [Wolfram Neural Net Repository][5] that more or less does what we want to do. If you have watched some of the [excellent training videos on neural nets][6] offered by Wolfram you will have noticed that the general suggestion is not to develop your own neural networks from scratch, but rather use what is already there and perhaps combine it, or adapt it so that you can achieve what you want. This is also very well described in this recent [blog-post by experts on the topic][7]. I am usually happy if I can use the work of others and do not have to re-invent the wheel. &#xD;
&#xD;
If you read the posts describing how to build a network that have only seen beautiful things, you will find that they used a variation of the pix2pix network and an implementation in tensorflow (a &amp;#034;conditional adversarial network&amp;#034;).  If you go through the extensive list of networks that are offered on the Wolfram Neural Net Repository you will see that there are Pix2pix resources, e.g. &#xD;
&#xD;
    ResourceObject[&amp;#034;Pix2pix Photo-To-Street-Map Translation&amp;#034;]&#xD;
&#xD;
or &#xD;
&#xD;
    net=ResourceObject[&amp;#034;Pix2pix Street-Map-To-Photo Translation&amp;#034;]&#xD;
&#xD;
I will use the latter resource object, but that does not actually matter. Next, we will need to build a training set. &#xD;
&#xD;
Scraping data for the training set&#xD;
----------&#xD;
&#xD;
The next thing we need is a solid training set. My first attempt was to use ServiceConnect with the google search to obtain lots of images of flowers. &#xD;
&#xD;
    googleCS = ServiceConnect[&amp;#034;GoogleCustomSearch&amp;#034;]&#xD;
    imgs = ServiceExecute[&amp;#034;GoogleCustomSearch&amp;#034;, &#xD;
       &amp;#034;Search&amp;#034;, {&amp;#034;Query&amp;#034; -&amp;gt; &amp;#034;Flowers&amp;#034;, MaxItems -&amp;gt; 1000, &#xD;
        &amp;#034;SearchType&amp;#034; -&amp;gt; &amp;#034;Image&amp;#034;}];&#xD;
&#xD;
It turns out that the max of results returned is only 100, which is not enough for our purpose. I tried to fix this by using&#xD;
&#xD;
    imgs2 = ServiceExecute[&amp;#034;GoogleCustomSearch&amp;#034;, &#xD;
       &amp;#034;Search&amp;#034;, {&amp;#034;Query&amp;#034; -&amp;gt; &amp;#034;Flowers&amp;#034;, MaxItems -&amp;gt; 1000, &#xD;
        &amp;#034;StartIndex&amp;#034; -&amp;gt; 101, &amp;#034;SearchType&amp;#034; -&amp;gt; &amp;#034;Image&amp;#034;}];&#xD;
&#xD;
but that did not work. So WebImageSearch is the way to go. It does cost ServiceCredits, but the costs are relatively limited. Let&amp;#039;s download information on 1000 images of flowers:&#xD;
&#xD;
    imgswebsearch = WebImageSearch[&amp;#034;Flowers&amp;#034;, MaxItems -&amp;gt; 1000];&#xD;
    Export[&amp;#034;~/Desktop/imglinks.mx&amp;#034;, imgswebsearch]&#xD;
&#xD;
A WebImageSearch of up to 10 results costs 3 ServiceCredits. So this should be 300 credits. 500 credits can be bought for $3, and 5000 for $25 (+VAT). This would mean the generation of our training set comes in at maximally $1.8, which is manageable - particularly if we consider the price of the eGPU that we will use later on.... Just in case we export the result, because we paid for it and might have to recover it later if we suffer a kernel crash or something. &#xD;
&#xD;
Alright. Now we have a dataset that looks more or less like this:&#xD;
&#xD;
![enter image description here][8]&#xD;
&#xD;
Great. That contains the &amp;#034;ImageHyperlink&amp;#034; which we will now use to download all the images:&#xD;
&#xD;
    rawimgs = Import /@ (&amp;#034;ImageHyperlink&amp;#034; /. Normal[imgswebsearch]);&#xD;
    Export[&amp;#034;~/Desktop/rawimgs.mx&amp;#034;, rawimgs]&#xD;
&#xD;
Again, we export the result (better safe than sorry!). Let&amp;#039;s make the images conform:&#xD;
&#xD;
    imagesconform = ConformImages[Select[rawimgs, ImageQ]];&#xD;
&#xD;
By using Select[...,ImageQ] we make sure that we use only images; and not error messages of the cases where it didn&amp;#039;t work. &#xD;
&#xD;
Generating a training set&#xD;
----------&#xD;
&#xD;
&#xD;
In the original posts they suggest that they used edges, i.e. EdgeDetect to generate partial information of the images, and then linked that to the full image like so:&#xD;
&#xD;
    rules = ImageAdjust[EdgeDetect[ImageAdjust[#]]] -&amp;gt; # &amp;amp; /@ imagesconform;&#xD;
&#xD;
It turns out that my results with that were less than impressive so I went for a more time consuming approach that gave better results. I used &#xD;
&#xD;
    Monitor[rulesnew = Table[Colorize[ClusteringComponents[rules[[i, 2]], 7]] -&amp;gt; rules[[i, 2]], {i, 1, Length[rules]}];, I]&#xD;
&#xD;
i.e. ClusteringComponents to generate a trainingset. Partial information on the images now looked like this:&#xD;
&#xD;
![enter image description here][9]&#xD;
&#xD;
rather than &#xD;
&#xD;
![enter image description here][10]&#xD;
&#xD;
when we use EdgeDetect. Our training data set now links the image with partial (CluseteringComponents) information via a rule to the original image. Basically, we give partial information of the world and train the network to see flowers. Just in case we export the data set like so:&#xD;
&#xD;
    Export[&amp;#034;~/Desktop/rulesnew.mx&amp;#034;, rulesnew]&#xD;
&#xD;
Training the network&#xD;
----------&#xD;
&#xD;
If you want to train on the EdgeDetect version you can use:&#xD;
&#xD;
    retrainednet = NetTrain[net, rules, TargetDevice -&amp;gt; &amp;#034;GPU&amp;#034;, TrainingProgressReporting -&amp;gt; &amp;#034;Panel&amp;#034;, TimeGoal -&amp;gt; Quantity[120, &amp;#034;Minutes&amp;#034;]]&#xD;
&#xD;
otherwise you can use&#xD;
&#xD;
    retrainednet2 = NetTrain[net, rulesnew, TargetDevice -&amp;gt; &amp;#034;GPU&amp;#034;, TrainingProgressReporting -&amp;gt; &amp;#034;Panel&amp;#034;, TimeGoal -&amp;gt; Quantity[120, &amp;#034;Minutes&amp;#034;]]&#xD;
&#xD;
Note that I use a GPU and considerable training time (2h). On a CPU this would take quite a while. Here are typical results of the EdgeDetect network:&#xD;
&#xD;
    retrainednet[EdgeDetect[CurrentImage[], 0.7]]&#xD;
&#xD;
![enter image description here][11]&#xD;
&#xD;
and the ClusteringComponents one:&#xD;
&#xD;
![enter image description here][12]&#xD;
&#xD;
We should not forget to export the network:&#xD;
&#xD;
    Export[&amp;#034;~/Desktop/teachnwnicethings2.wlnet&amp;#034;, retrainednet2]&#xD;
&#xD;
More examples&#xD;
----------&#xD;
&#xD;
Let&amp;#039;s look at the ClusteringComponents network a bit closer. We apply &#xD;
&#xD;
    GraphicsRow[{ImageResize[#, {256, 256}], beautifulnet[Colorize[ClusteringComponents[#, 7]]]}] &amp;amp;&#xD;
&#xD;
to different images to obtain:&#xD;
&#xD;
![enter image description here][13]&#xD;
&#xD;
Application to videos&#xD;
&#xD;
----------&#xD;
&#xD;
Suppose that I have the frames of a recorded movie stored in the variable movie1. Then load our network into the function beautifulnet&#xD;
&#xD;
    beautifulnet = Import[&amp;#034;/Users/thiel/Desktop/teachnwnicethings2.wlnet&amp;#034;]&#xD;
&#xD;
Then the following will generate frames for an animation:&#xD;
&#xD;
    animation1 = GraphicsRow[{ImageResize[#, {256, 256}], beautifulnet[Colorize[ClusteringComponents[#, 7]]]}] &amp;amp; /@ movie1;&#xD;
&#xD;
We can animate this like so:&#xD;
&#xD;
    ListAnimate[animation1]&#xD;
&#xD;
![enter image description here][14]&#xD;
&#xD;
Conclusion&#xD;
----------&#xD;
&#xD;
These are only very preliminary results. But we see the workflow from scraping data, via generating a training set, choosing a network and training it. I think that having more images and more training, perhaps a small change of the net might give us much better results.  The video is quite bad, because we should use a better object than &amp;#034;four cables in a hand&amp;#034;. It is also a bit debatable whether it is ok to say that this is how a network that only has seen beautiful things interprets the world, but I couldn&amp;#039;t resit the hype. Sorry for that!&#xD;
&#xD;
This is certainly in the realm of &amp;#034;recreational use of the Wolfram Language&amp;#034;, but the network does appear to make the world more colourful and provides a very special interpretation of the world. I hope that people in this forum who are better than me at this ([@Sebastian Bodenstein][at0] , [@Matteo Salvarezza][at1] , [@Meghan Rieu-Werden][at2] , [@Vitaliy Kaurov][at3] ?) can improve on the results. &#xD;
&#xD;
Cheers,&#xD;
&#xD;
Marco&#xD;
&#xD;
 [at0]: http://community.wolfram.com/web/sebastianb&#xD;
&#xD;
 [at1]: http://community.wolfram.com/web/matteosalvarezza&#xD;
&#xD;
 [at2]: http://community.wolfram.com/web/meghanr&#xD;
&#xD;
 [at3]: http://community.wolfram.com/web/vitaliyk&#xD;
&#xD;
&#xD;
  [1]: http://www.memo.tv/learning-to-see-you-are-what-you-see/&#xD;
  [2]: https://vimeo.com/260612034&#xD;
  [3]: http://community.wolfram.com//c/portal/getImageAttachment?filename=Screenshot2018-07-0600.33.06.png&amp;amp;userId=48754&#xD;
  [4]: http://community.wolfram.com//c/portal/getImageAttachment?filename=1838animated.gif&amp;amp;userId=48754&#xD;
  [5]: https://resources.wolframcloud.com/NeuralNetRepository/&#xD;
  [6]: http://www.wolfram.com/broadcast/s?sx=neural%20networks&amp;amp;c=105&amp;amp;v=1522&#xD;
  [7]: http://blog.wolfram.com/2018/06/14/launching-the-wolfram-neural-net-repository/&#xD;
  [8]: http://community.wolfram.com//c/portal/getImageAttachment?filename=Screenshot2018-07-0523.04.32.png&amp;amp;userId=48754&#xD;
  [9]: http://community.wolfram.com//c/portal/getImageAttachment?filename=Screenshot2018-07-0523.13.54.png&amp;amp;userId=48754&#xD;
  [10]: http://community.wolfram.com//c/portal/getImageAttachment?filename=Screenshot2018-07-0523.15.48.png&amp;amp;userId=48754&#xD;
  [11]: http://community.wolfram.com//c/portal/getImageAttachment?filename=Screenshot2018-07-0523.21.05.png&amp;amp;userId=48754&#xD;
  [12]: http://community.wolfram.com//c/portal/getImageAttachment?filename=Screenshot2018-07-0523.22.34.png&amp;amp;userId=48754&#xD;
  [13]: http://community.wolfram.com//c/portal/getImageAttachment?filename=resulttable.png&amp;amp;userId=48754&#xD;
  [14]: http://community.wolfram.com//c/portal/getImageAttachment?filename=1838animated.gif&amp;amp;userId=48754</description>
    <dc:creator>Marco Thiel</dc:creator>
    <dc:date>2018-07-05T23:14:51Z</dc:date>
  </item>
  <item rdf:about="https://community.wolfram.com/groups/-/m/t/1851854">
    <title>Circular Diagram of the Wolfram Neural Net Repository</title>
    <link>https://community.wolfram.com/groups/-/m/t/1851854</link>
    <description>![enter image description here][1]&#xD;
&#xD;
![enter image description here][2]&#xD;
&#xD;
[The Wolfram Neural Net Repository][3] has published 95 NN models for various TaskTypes by 2019. This circular diagram visualizes the information contained in them. &#xD;
&#xD;
&#xD;
&#xD;
 **view of circluar diagram**&#xD;
&#xD;
 - An arc indicates one NN model. The arcs are ordered clockwise from the 12 o&amp;#039;clock position in the order of the year the model was released.&#xD;
 - The outermost circumference is the TaskType. In addition, the name of NN models is displayed by Tooltip.&#xD;
 - The inner circumference is the usage status of the Layer function of each NN model. White indicates that the Layer function is not used, and the darker the color, the more frequently the Layer function is used. In addition, the specific usage count is displayed by Tooltip.&#xD;
 - The innermost circumference is the total number of parameters. The higher the height of the bar graph, the bigger the total number of parameters. In addition, the specific number is displayed by Tooltip.&#xD;
&#xD;
**TaskType**&#xD;
&#xD;
There are 10 TaskTypes. The legend of TaskTypes is at the top left of the figure. The trends are as follows.&#xD;
&#xD;
- Top 3 is Classification: 26, Feature Extraction: 18, Image Processing: 18, accounting for 65% of the total 95 models&#xD;
- Classification and Feature Extraction are released stably every year&#xD;
- Language Modeling, Audio Analysis, Object Detection are recent trends&#xD;
&#xD;
**LayerTypeCounts**&#xD;
&#xD;
In 95 NN models, 36 Layer functions are used. The trends are as follows.&#xD;
&#xD;
- The 4 most used Layer functions are BatchNormalizationLayer, ConvolutionLayer, ElementwiseLayer, LinearLayer.&#xD;
- &amp;#034;YOLO V2 Trained on MS-COCO Data&amp;#034; and &amp;#034;CapsNet Trained on MNIST Data&amp;#034; use the most types of Layer functions, and they use 14 types of Layer functions.&#xD;
- Some models use only one Layer function(EmbeddingLayer), and their TaskType are Feature Extraction(e.g. GloVe). &#xD;
- It is difficult to understand from the diagram, but those whose count exceeds 1000 are &amp;#034;Enhanced Super-Resolution GAN Trained on DIV2K, Flickr2K and OST Data&amp;#034; and &amp;#034;Unguided Volumetric Regression Net for 3D Face Reconstruction&amp;#034;. The count of BERT that are producing impressive results in language processing is 862. On the other hand, the only NN model &amp;#034;Sketch-RNN Trained on QuickDraw Data&amp;#034; which TaskType is Data Generation makes very interesting inferences even though it uses only 3 Layer functions.&#xD;
&#xD;
**the total number of parameters**&#xD;
&#xD;
The total number of parameters is from the minimum 0.1 M of &amp;#034;Vanilla CNN for Facial Landmark Regression&amp;#034; to the maximum 659 M of &amp;#034;GloVe 300-Dimensional Word Vectors Trained on Common Crawl 840B&amp;#034;.&#xD;
There are 23 NN models with a total number of parameters exceeding 100M, which is about 1/4 of all. Feature extraction: 8, classification: 7, semantic segmentation: 6, language modeling: 2.&#xD;
&#xD;
Get the data&#xD;
==============&#xD;
I will explain how to make this circluar diagram.&#xD;
&#xD;
Create a list consisting of the following elements for all the NN models published in The Wolfram Neural Net Repository.&#xD;
&#xD;
- name&#xD;
- release year&#xD;
- TaskType&#xD;
- Total Number of Parameter&#xD;
- list of number of Layer functions used in it&#xD;
&#xD;
        (* Get all the NN models published in the Wolfram Neural Net Repository?*)&#xD;
        modelnames = NetModel[];&#xD;
        models = NetModel /@ modelnames;&#xD;
        (* {name, release year, TaskType,?Total Number of Parameter} *)&#xD;
        list = {#, NetModel[#, &amp;#034;SourceMetadata&amp;#034;][&amp;#034;Date&amp;#034;], &#xD;
             NetModel[#, &amp;#034;TaskType&amp;#034;], &#xD;
             NetInformation[NetModel[#], &amp;#034;ArraysTotalElementCount&amp;#034;]} &amp;amp; /@ &#xD;
           modelnames;&#xD;
&#xD;
Correct missing data.&#xD;
&#xD;
    (* correct release year from the description of The Wolfram Neural Net Repository *)&#xD;
    list[[First@&#xD;
        First@Position[modelnames, &#xD;
          &amp;#034;ResNet-101 Trained on YFCC100m Geotagged Data&amp;#034;], 2]] = &#xD;
      DateObject[{2017}];&#xD;
    list[[First@First@Position[modelnames, &amp;#034;Yahoo Open NSFW Model V1&amp;#034;], &#xD;
       2]] = DateObject[{2016}];&#xD;
   &#xD;
    (* correct TaskType from the description of The Wolfram Neural Net Repository *)&#xD;
    list[[First@First@Position[modelnames, &amp;#034;LeNet&amp;#034;], &#xD;
       3]] = {&amp;#034;Classification&amp;#034;};&#xD;
&#xD;
    (* limited to one TaskType *)&#xD;
    list[[First@&#xD;
        First@Position[modelnames, &#xD;
          &amp;#034;GPT-2 Transformer Trained on WebText Data&amp;#034;], &#xD;
       3]] = {&amp;#034;Language Modeling&amp;#034;};&#xD;
    list[[First@&#xD;
        First@Position[modelnames, &#xD;
          &amp;#034;GPT Transformer Trained on BookCorpus Data&amp;#034;], &#xD;
       3]] = {&amp;#034;Language Modeling&amp;#034;};&#xD;
    list[[First@&#xD;
        First@Position[modelnames, &#xD;
          &amp;#034;Self-Normalizing Net for Numeric Data&amp;#034;], &#xD;
       3]] = {&amp;#034;Classification&amp;#034;};&#xD;
    list[[First@&#xD;
        First@Position[modelnames, &#xD;
          &amp;#034;Wolfram AudioIdentify V1 Trained on AudioSet Data&amp;#034;], &#xD;
       3]] = {&amp;#034;Audio Analysis&amp;#034;};&#xD;
&#xD;
Get a list of number of Layer functions used in NN models&#xD;
&#xD;
    (* Get all the Layer functions used in NN models *)&#xD;
    ltc = NetInformation[#, &amp;#034;LayerTypeCounts&amp;#034;] &amp;amp; /@ models;&#xD;
    apis = Keys[ltc] // Flatten // DeleteDuplicates // Sort;&#xD;
    (* List of number of Layer functions used in each NN model *)&#xD;
    rule = Map[# :&amp;gt; 0 &amp;amp;, apis];&#xD;
    apiscnt = (apis /. # /. rule) &amp;amp;@ltc;&#xD;
&#xD;
    (* {name of NN model, Year, TaskType,?Total Number of Parameter, &#xD;
    list of number of Layer functions } *)&#xD;
    list2 = Append[list[[#]], apiscnt[[#]]] &amp;amp; /@ Range[Length@models];&#xD;
&#xD;
Sort the list by release year and TaskType.&#xD;
&#xD;
    (*Sort by year*)&#xD;
    listSortDate = Sort[list2, #1[[2]] &amp;lt; #2[[2]] &amp;amp;];&#xD;
    (* Sort by TaskType *)&#xD;
    gbyear = GroupBy[listSortDate, #[[2]][[1, 1]] &amp;amp;];&#xD;
    sorttype = Sort /@ (#[[All, {3, 1, 2, 4, 5}]] &amp;amp; /@ gbyear);&#xD;
    reorder = (#[[All, {2, 3, 1, 4, 5}]]) &amp;amp; /@ sorttype;&#xD;
    listSortDateTask = Flatten[Values[reorder], 1];&#xD;
&#xD;
Create circluar diagram&#xD;
==============&#xD;
Set parameters independent of TaskType.&#xD;
&#xD;
    (* Background color *)&#xD;
    backcolor = White;&#xD;
    (* Number of Layer functions *)&#xD;
    an = Length@listSortDateTask[[1, -1]]; &#xD;
    (* List of TaskTypes *)&#xD;
    tasktypes = listSortDateTask[[All, 3]] // DeleteDuplicates // Sort;&#xD;
    (* Number of TaskTypes *)&#xD;
    tn = Length@tasktypes; &#xD;
    (* inner circle radius of circular diagram *)&#xD;
    R = 10; &#xD;
    (* Display range of circular diagram *)&#xD;
    c = 1.5 Pi;&#xD;
    (* bar chart ratio of Total Number of Parameter *)&#xD;
    psrate = R/(2 Max[&#xD;
          listSortDateTask[[All, 4]] /. &#xD;
           Indeterminate -&amp;gt; &#xD;
            0]);(* Max Total Number of Parameter of all NN models *)&#xD;
    psmax = Max[listSortDateTask[[All, 4]] /. Indeterminate -&amp;gt; 0];&#xD;
    &#xD;
    (* colors of Layer functions *)&#xD;
    SeedRandom[1];&#xD;
    col = RandomColor[an];&#xD;
    (* colors of TaskTypes from 12 colors of crayon *)&#xD;
    colt = {RGBColor[1, 1, 0], RGBColor[1, 0.5, 0], RGBColor[0.6, 0.4, 0.2], &#xD;
    RGBColor[1, 0, 0], RGBColor[1, 0.5, 0.5], RGBColor[0.5, 0, 0.5], &#xD;
    RGBColor[Rational[157, 255], Rational[4, 5], Rational[224, 255]], &#xD;
    RGBColor[Rational[181, 255], 1, Rational[4, 51]], RGBColor[0, 1, 0], RGBColor[0, 0, 1]};&#xD;
    (* get color of Layer functions. White if a function is not used *)&#xD;
    Col[n_, cnt_] := If[cnt[[n]] == 0, backcolor, col[[n]]]&#xD;
    (* get opacity of Layer functions depend on number of Layer function *)    &#xD;
    Opa[n_, cnt_] := &#xD;
     Which[cnt[[n]] == 0, 1, cnt[[n]] &amp;lt; 10, .1, cnt[[n]] &amp;lt; 100, .5, True, 1]&#xD;
&#xD;
Define functions.&#xD;
&#xD;
    (* cell for a layer function of a  model *)&#xD;
    cell[r_, {ang1_, ang2_}, col_, opa_, apiname_, apicount_] := {&#xD;
      (* front *)&#xD;
      Opacity[opa], col, &#xD;
      If[col === backcolor, Disk[{0, 0}, r, {ang1, ang2}], &#xD;
       Tooltip[Disk[{0, 0}, r, {ang1, ang2}], &#xD;
        ToString[apiname] &amp;lt;&amp;gt; &amp;#034; : &amp;#034; &amp;lt;&amp;gt; ToString[apicount] ]],&#xD;
      (* background *)&#xD;
      EdgeForm[{Thickness[0], backcolor}], Opacity[1], backcolor, &#xD;
      Disk[{0, 0}, r - 1, {ang1, ang2}]&#xD;
      }&#xD;
    &#xD;
    (* arc for a model *)&#xD;
    Arc[list_, modelno_, mn_] := Module[{theta, apicnt, coltt},&#xD;
      theta = {Pi/2 - (modelno - 1) c/mn, Pi/2 - modelno c/mn};&#xD;
      (* list of api count *)&#xD;
      apicnt = list[[modelno, -1]];&#xD;
      (* color of TaskType *)&#xD;
      coltt = &#xD;
       colt[[First@First@Position[tasktypes, list[[modelno, 3]]]]];&#xD;
      Join[&#xD;
       (* TaskType *)&#xD;
       {EdgeForm[{Thickness[0], backcolor}], coltt, &#xD;
        Tooltip[Disk[{0, 0}, an + R + 1.5, theta], list[[modelno, 1]]]},&#xD;
       (* background *)&#xD;
       {EdgeForm[{Thickness[0], backcolor}], backcolor, &#xD;
        Disk[{0, 0}, an + R + .5, theta]},&#xD;
       (* cells of all Layer functions of NN model *)&#xD;
       cell[an + R + 1 - #, theta, Col[#, apicnt], Opa[#, apicnt], &#xD;
          apis[[#]], apicnt[[#]]] &amp;amp; /@ Range[an]&#xD;
       ]&#xD;
      ]&#xD;
    &#xD;
    (* Total Number of Parameter *)&#xD;
    tnp[list_, modelno_, mn_] := Module[{theta, psize},&#xD;
      theta = {Pi/2 - (modelno - 1) c/mn, Pi/2 - modelno c/mn};&#xD;
      psize = list[[modelno, 4]];(* Total Number of Parameter *)&#xD;
      If[psize === Indeterminate, psize = 0;];&#xD;
      {Gray, Thickness[.0025], &#xD;
       Rotate[Tooltip[&#xD;
         Line[{{R/2 - 1, 0}, {R/2 - 1 + (R/2) Sqrt[psize/psmax], 0}}], &#xD;
         psize], Mean@theta, {0, 0}]} &#xD;
      ]&#xD;
    &#xD;
    (* circular diagram *)&#xD;
    circulardiagram[tt_: 0] := &#xD;
     Module[{listsel, yearnames, yearacc, yearmv, mn},&#xD;
      (* Parameters dependent of TaskType *)&#xD;
      listsel = &#xD;
       If[tt === 0, listSortDateTask, &#xD;
        Select[listSortDateTask, #[[3]] === tt &amp;amp;]];&#xD;
      mn = Length@listsel ;(* Number of NN Models *)&#xD;
      &#xD;
      (* year information *)&#xD;
      yearnames = (gb = GroupBy[listsel, #[[2]][[1, 1]] &amp;amp;]) // Keys;&#xD;
      yearacc = Prepend[(Length /@ gb // Values // Accumulate), 0];&#xD;
      yearmv = MovingAverage[yearacc, 2];&#xD;
      &#xD;
      Graphics[Join[&#xD;
        (* NN model *)&#xD;
        Arc[listsel, #, mn] &amp;amp; /@ Range[mn],&#xD;
        (* index: name &amp;amp; TaskType *)&#xD;
        {Text[&#xD;
          Style[&amp;#034;Model name &amp;amp; TaskType   &amp;#034;, Gray, Bold, 6], {0, &#xD;
           an + R + 1}, Right]},&#xD;
        (* index: Layer function name *)&#xD;
        Text[Style[ToString[apis[[#]]] &amp;lt;&amp;gt; &amp;#034;&amp;#034;, Gray, Bold, 6], {-1.5, &#xD;
            an + R + 1 - .5 - #}, Right] &amp;amp; /@ Range[an],&#xD;
        (* index: Layer function color *)&#xD;
        {EdgeForm[{Thickness[0], col[[#]]}], FaceForm[col[[#]]], &#xD;
           Disk[{-1, an + R + 1 - .5 - #}, .3]} &amp;amp; /@ Range[an],&#xD;
        (* index: Total Number of Parameters *)&#xD;
        {Text[&#xD;
          Style[&amp;#034;Total Number of Parameters   &amp;#034;, Gray, Bold, 6], {0, &#xD;
           R/2 + 2}, Right]},&#xD;
        (* border line *)&#xD;
        {LightGray, Thickness[.001], &#xD;
           Rotate[Line[{{R, 0}, {an + R + 1, 0}}], &#xD;
            Pi/2 - # c/mn, {0, 0}]} &amp;amp; /@ Range[mn],(* release year border line *)&#xD;
        {LightGray, Thickness[.003], &#xD;
           Rotate[Line[{{R, 0}, {an + R + 2, 0}}], &#xD;
            Pi/2 - # c/mn, {0, 0}]} &amp;amp; /@ yearacc,&#xD;
        {EdgeForm[{Thickness[.002], LightGray}], FaceForm[None], &#xD;
         Disk[{0, 0}, R, {-Pi, Pi/2}]},&#xD;
        {EdgeForm[{Thickness[.001], LightGray}], FaceForm[None], &#xD;
           Disk[{0, 0}, R + #, {-Pi, Pi/2}]} &amp;amp; /@ Range[an],(* inner circle edge *)&#xD;
        {EdgeForm[{Thickness[.002], LightGray}], FaceForm[None], &#xD;
         Disk[{0, 0}, &#xD;
          R/2 - 1, {-Pi, Pi/2}]}, {EdgeForm[{Thickness[0], backcolor}], &#xD;
         FaceForm[backcolor], Disk[{0, 0}, R/2 - 1 - .1]},&#xD;
        (* release year *)&#xD;
        Text[Style[ToString[yearnames[[#]]], Gray, Bold, &#xD;
            11], (an + R + 3) {Cos[tmp = Pi/2 - yearmv[[#]] c/mn], &#xD;
             Sin[tmp]}, Center, {Sin[tmp], -Cos[tmp]}] &amp;amp; /@ &#xD;
         Range[Length@yearnames],&#xD;
        (* Total Number of Parameter *)&#xD;
        tnp[listsel, #, mn] &amp;amp; /@ Range[mn]&#xD;
        ],&#xD;
       (* usage guide of TaskTypes *)&#xD;
       Epilog -&amp;gt; &#xD;
        If[tt === 0, &#xD;
         Inset[Grid[&#xD;
           Prepend[Transpose[{colt, &#xD;
              Style[#, Bold, Gray, 8] &amp;amp; /@ tasktypes[[All, 1]]}], {Style[&#xD;
              &amp;#034;Task Type&amp;#034;, Bold, Gray, 10], SpanFromLeft}], &#xD;
           Alignment -&amp;gt; Left], {-an - R + 8, an + R - 9}],&#xD;
         Inset[Null]],&#xD;
       ImageSize -&amp;gt; If[tt === 0, 700, 350], Background -&amp;gt; backcolor,&#xD;
       PlotLabel -&amp;gt; If[tt === 0, None, Style[First@tt, Gray, Bold, 13]]&#xD;
       ]&#xD;
      ]&#xD;
&#xD;
Create the circular diagram at the top of this post.&#xD;
&#xD;
    circulardiagram[]&#xD;
&#xD;
![enter image description here][4]&#xD;
&#xD;
Create circular diagram for each TaskType.&#xD;
&#xD;
    Grid[Partition[circulardiagram /@ tasktypes, UpTo[3]], &#xD;
     Spacings -&amp;gt; {2, 2}]&#xD;
&#xD;
![enter image description here][5]&#xD;
&#xD;
&#xD;
  [1]: https://community.wolfram.com//c/portal/getImageAttachment?filename=cd202301_300.png&amp;amp;userId=11733&#xD;
  [2]: https://community.wolfram.com//c/portal/getImageAttachment?filename=f01.jpg&amp;amp;userId=1013863&#xD;
  [3]: https://resources.wolframcloud.com/NeuralNetRepository/&#xD;
  [4]: https://community.wolfram.com//c/portal/getImageAttachment?filename=f01.jpg&amp;amp;userId=1013863&#xD;
  [5]: https://community.wolfram.com//c/portal/getImageAttachment?filename=f02.jpg&amp;amp;userId=1013863</description>
    <dc:creator>Kotaro Okazaki</dc:creator>
    <dc:date>2020-01-03T23:32:02Z</dc:date>
  </item>
  <item rdf:about="https://community.wolfram.com/groups/-/m/t/2328597">
    <title>Training a recurrent neural network (RNN) to generate piano music</title>
    <link>https://community.wolfram.com/groups/-/m/t/2328597</link>
    <description>&amp;gt; **GitHub Repository:** https://github.com/alecGraves/Howl&#xD;
&#xD;
&#xD;
&#xD;
&amp;amp;[Wolfram Notebook][1]&#xD;
&#xD;
&#xD;
  [1]: https://www.wolframcloud.com/obj/da6d3b76-7bbf-4a55-9fcd-058e7f1e17bf</description>
    <dc:creator>Alec Graves</dc:creator>
    <dc:date>2021-07-27T14:09:12Z</dc:date>
  </item>
  <item rdf:about="https://community.wolfram.com/groups/-/m/t/562203">
    <title>[BOOK+SCREENCASTS] Digital Research Methods with Mathematica</title>
    <link>https://community.wolfram.com/groups/-/m/t/562203</link>
    <description>*WOLFRAM MATERIALS for the ARTICLE:*&#xD;
&amp;gt; William J Turkel, Digital Research Methods with Mathematica.&#xD;
&#xD;
&amp;gt; https://williamjturkel.net/digital-research-methods-with-mathematica/&#xD;
&#xD;
&amp;gt; [Full book in notebook][1]&#xD;
&#xD;
&amp;gt; [GitHub Repository][2]&#xD;
&#xD;
This summer (2020) I revised the second edition of my open content, open access and open source textbook *Digital Research Methods with Mathematica*. It is freely available as a Mathematica notebook which can be accessed with either the Mathematica software or with Wolfram&amp;#039;s free Wolfram Player. The content remains mostly the same as the previous version with a few minor edits. New in this edition are more than 100 short screencasts which I created to support online learning during the COVID-19 pandemic.&#xD;
&#xD;
https://williamjturkel.net/digital-research-methods-with-mathematica&#xD;
&#xD;
[![enter image description here][3]](https://williamjturkel.net/digital-research-methods-with-mathematica)&#xD;
&#xD;
The book focuses on learning to read code to the point where one can modify it to solve related research problems. Here are the topics that are covered.&#xD;
&#xD;
 1. Introduction to Mathematica. Interacting with notebooks.&#xD;
 2. Reading Code. Word frequency, word clouds and stopwords.&#xD;
 3. Computable Knowledge. Entities, tables, timelines and maps.&#xD;
 4. Text Content. Mathematica notebooks and expressions, strings and natural language processing.&#xD;
 5. Data Structures. Lists, associations and datasets.&#xD;
 6. Reusing Code. Defining and developing functions, keyword in context (KWIC).&#xD;
 7. Networks. Metadata, matrices and social network analysis.&#xD;
 8. Indexing and Searching. Pattern matching, topic classification and term distribution.&#xD;
 9. Geospatial Analysis. Geographic information: raster, vector and attribute data.&#xD;
 10. Images. Computer vision, face detection, feature extraction and image mining.&#xD;
 11. Page Images. Optical character recognition (OCR), figure extraction and classification.&#xD;
 12. Crawling. Browser automation, batch downloading, web archives and WARC files.&#xD;
 13. Linked Open Data. Resource description framework (RDF), SPARQL queries and endpoints, JSON-LD.&#xD;
 14. Markup Languages. Scraping and parsing, XML, really simple syndication (RSS) and text encoding initiative (TEI).&#xD;
 15. Studying Societies. Computational social science, search data, social media and social networks.&#xD;
 16. Extracting Keywords. Information retrieval, term frequency-inverse document frequency (TF-IDF) and rapid automatic keyword extraction (RAKE).&#xD;
 17. Word and Document Vectors. Feature extraction, dimension reduction, word embeddings and global vectors.&#xD;
 18. References, web services, bibliographic linked open data and citation networks.&#xD;
 19. Natural Language. Multilingual analysis, computational linguistics and sentiment analysis.&#xD;
 20. Web Services. Entity networks, publication search, dashboards, manipulating JSON.&#xD;
 21. Databases. Parts, selections and transformations, computations and querying, relations.&#xD;
 22. Measuring Images. Photogrammetry, georectification, handwriting and facial 3D reconstruction.&#xD;
 23. Machine Learning. Unsupervised clustering, classify, predict and transfer learning.&#xD;
&#xD;
## SAMPLE PAGES: Lesson 21.3. Measuring Images: Handwriting&#xD;
&#xD;
&amp;amp;[Wolfram Notebook][4]&#xD;
&#xD;
&#xD;
  [1]: https://github.com/williamjturkel/Digital-Research-Methods-2nd-Ed/releases/download/v2.01/turkel-digital-research-methods-with-mathematica-2nd-ed-rev-01-2020.nb&#xD;
  [2]: https://github.com/williamjturkel/Digital-Research-Methods-2nd-Ed&#xD;
  [3]: https://community.wolfram.com//c/portal/getImageAttachment?filename=digital-research-methods-2-rev-01-cover-2020.jpg&amp;amp;userId=90045&#xD;
  [4]: https://www.wolframcloud.com/obj/5d6eb35b-79bf-4d18-979f-9833d7f25878</description>
    <dc:creator>William Turkel</dc:creator>
    <dc:date>2015-09-08T19:25:28Z</dc:date>
  </item>
  <item rdf:about="https://community.wolfram.com/groups/-/m/t/1341081">
    <title>UNET image segmentation in stem cells research</title>
    <link>https://community.wolfram.com/groups/-/m/t/1341081</link>
    <description>For my research project I had to encounter a thorny problem. But before I tell about the problem I would like to briefly mention something about my research project. Basically I am using embryonic stem cells that self-organize to form spheroids (balls of cells) to study gastrulation events. In order to not bog down the readers with technical jargon, gastrulation is a process where the stem cells start to form the different layers; each layer then goes onto form the various tissues/organs, in the process unraveling the developmental plan of the entire organism. I am using experimental techniques and quantitative principles from biophysics and engineering to understand some aspects of this crucial process&#xD;
&#xD;
Now coming back to the problem at hand, the gastruloids (image below) are quite rough in their appearance and not as beautiful as one would like them to be (only a mother can love such an image). Any means of quantifying these gastruloids requires me to initially segment them. When you see a time-lapse images of gastruloids it becomes apparent that they shed a lot of cells (for reasons I do not know yet). This adds considerable noise to the system; oftentimes to the point that  as a human  my eyes are fooled and run into the difficulty of finding the right contours for the spheroids. Here comes the disclosure: classical means/operations in image-processing (gradients and edge detection, filtering, morphological operations etc.. ) prove utterly futile for image segmentation in my case.&#xD;
&#xD;
![enter image description here][1]&#xD;
&#xD;
(A gastruloid  virtually a ball of cells with many shed around the periphery)&#xD;
&#xD;
So what can you do to address the problem where even the best image processing tool in existence   the human eyes  fails. This is precisely where you take help of neural networks. Neural networks are selling like hotcakes during the recent years and added life and hope to the once dead area of artificial intelligence. Again to avoid underlying technical details, neural networks is a paradigm utilized by the computer to mimic the working of a human brain by taking into account the complex interactions between the cells  but only digitally. There are many flavours of neural networks out there, each one geared towards performing a specific task. With advancements made in the area of deep learning/artificial intelligence, the neural nets have started to surpass humans in tasks that humans have been known to be best for i.e. classification tasks. A few recent examples that come to mind include Googles AlphaGo beating the former World Go champion and an AI diagnosing skin cancer with an unprecedented accuracy.&#xD;
&#xD;
I utilized one such flavour of neural networks (a deep convolutional network  termed as UNET) to solve my longstanding problem. I constructed the network in Wolfram-Language with external help from Alexey Golyshev. UNET is a deep convolutional network that has a series of convolutional and pooling operations in the contraction phase of the net (wherein the features are extracted) and a sequence of deconvolution &amp;amp; convolution operations in the expansion phase which then yields an output from the network. This output can be subjected to a threshold to ultimately generate a binarized mask (the image segmentation).&#xD;
&#xD;
![enter image description here][2]&#xD;
&#xD;
The architecture of UNET as provided by the author:  https://lmb.informatik.uni-freiburg.de/people/ronneber/u-net/&#xD;
&#xD;
    (* ::Package:: *)&#xD;
    BeginPackage[&amp;#034;UNETSegmentation`&amp;#034;]&#xD;
        &#xD;
    (* ::Section:: *)&#xD;
    (*Creating  UNet*)&#xD;
        &#xD;
    conv[n_]:=NetChain[&#xD;
    {&#xD;
     ConvolutionLayer[n,3,&amp;#034;PaddingSize&amp;#034;-&amp;gt;{1,1}],&#xD;
     Ramp,&#xD;
     BatchNormalizationLayer[],&#xD;
     ConvolutionLayer[n,3,&amp;#034;PaddingSize&amp;#034;-&amp;gt;{1,1}],&#xD;
     Ramp,&#xD;
     BatchNormalizationLayer[]&#xD;
    }&#xD;
    ];&#xD;
        &#xD;
    pool := PoolingLayer[{2,2},2];&#xD;
    &#xD;
    dec[n_]:=NetGraph[&#xD;
    {&#xD;
     &amp;#034;deconv&amp;#034; -&amp;gt; DeconvolutionLayer[n,{2,2},&amp;#034;Stride&amp;#034;-&amp;gt;{2,2}],&#xD;
     &amp;#034;cat&amp;#034; -&amp;gt; CatenateLayer[],&#xD;
     &amp;#034;conv&amp;#034; -&amp;gt; conv[n]&#xD;
    },&#xD;
    {&#xD;
     NetPort[&amp;#034;Input1&amp;#034;]-&amp;gt;&amp;#034;cat&amp;#034;,&#xD;
     NetPort[&amp;#034;Input2&amp;#034;]-&amp;gt;&amp;#034;deconv&amp;#034;-&amp;gt;&amp;#034;cat&amp;#034;-&amp;gt;&amp;#034;conv&amp;#034;&#xD;
    }&#xD;
    ];&#xD;
        &#xD;
    nodeGraphMXNET[net_,opt: (&amp;#034;MXNetNodeGraph&amp;#034;|&amp;#034;MXNetNodeGraphPlot&amp;#034;)]:= net~NetInformation~opt;&#xD;
        &#xD;
    UNET := NetGraph[&#xD;
    &amp;lt;|&#xD;
    &amp;#034;enc_1&amp;#034;-&amp;gt; conv[64],&#xD;
    &amp;#034;enc_2&amp;#034;-&amp;gt; {pool,conv[128]},&#xD;
    &amp;#034;enc_3&amp;#034;-&amp;gt; {pool,conv[256]},&#xD;
    &amp;#034;enc_4&amp;#034;-&amp;gt; {pool,conv[512]},&#xD;
    &amp;#034;enc_5&amp;#034;-&amp;gt; {pool,conv[1024]},&#xD;
    &amp;#034;dec_1&amp;#034;-&amp;gt; dec[512],&#xD;
    &amp;#034;dec_2&amp;#034;-&amp;gt; dec[256],&#xD;
    &amp;#034;dec_3&amp;#034;-&amp;gt; dec[128],&#xD;
    &amp;#034;dec_4&amp;#034;-&amp;gt; dec[64],&#xD;
    &amp;#034;map&amp;#034;-&amp;gt;{ConvolutionLayer[1,{1,1}],LogisticSigmoid}&#xD;
    |&amp;gt;,&#xD;
    {&#xD;
    NetPort[&amp;#034;Input&amp;#034;]-&amp;gt;&amp;#034;enc_1&amp;#034;-&amp;gt;&amp;#034;enc_2&amp;#034;-&amp;gt;&amp;#034;enc_3&amp;#034;-&amp;gt;&amp;#034;enc_4&amp;#034;-&amp;gt;&amp;#034;enc_5&amp;#034;,&#xD;
    {&amp;#034;enc_4&amp;#034;,&amp;#034;enc_5&amp;#034;}-&amp;gt;&amp;#034;dec_1&amp;#034;,&#xD;
    {&amp;#034;enc_3&amp;#034;,&amp;#034;dec_1&amp;#034;}-&amp;gt;&amp;#034;dec_2&amp;#034;,&#xD;
    {&amp;#034;enc_2&amp;#034;,&amp;#034;dec_2&amp;#034;}-&amp;gt;&amp;#034;dec_3&amp;#034;,&#xD;
    {&amp;#034;enc_1&amp;#034;,&amp;#034;dec_3&amp;#034;}-&amp;gt;&amp;#034;dec_4&amp;#034;,&#xD;
    &amp;#034;dec_4&amp;#034;-&amp;gt;&amp;#034;map&amp;#034;},&#xD;
    &amp;#034;Input&amp;#034;-&amp;gt;NetEncoder[{&amp;#034;Image&amp;#034;,{160,160},ColorSpace-&amp;gt;&amp;#034;Grayscale&amp;#034;}]&#xD;
    ]&#xD;
    &#xD;
    (* ::Section:: *)&#xD;
    (*DataPrep*)&#xD;
        &#xD;
    dataPrep[dirImage_,dirMask_]:=Module[{X, masks,imgfilenames, maskfilenames,ordering, fNames,func},&#xD;
    &#xD;
    func[dir_] := (SetDirectory[dir];&#xD;
    fNames = FileNames[];&#xD;
    ordering = Flatten@StringCases[fNames,x_~~p:DigitCharacter.. :&amp;gt; ToExpression@p];&#xD;
    Part[fNames,Ordering@ordering]);&#xD;
    &#xD;
    imgfilenames = func@dirImage;&#xD;
    X = ImageResize[Import[dirImage&amp;lt;&amp;gt;&amp;#034;\\&amp;#034;&amp;lt;&amp;gt;#],{160,160}]&amp;amp;/@imgfilenames;&#xD;
    maskfilenames = func@dirMask;&#xD;
    masks = Import[dirMask&amp;lt;&amp;gt;&amp;#034;\\&amp;#034;&amp;lt;&amp;gt;#]&amp;amp;/@maskfilenames;&#xD;
    {X, NetEncoder[{&amp;#034;Image&amp;#034;,{160,160},ColorSpace-&amp;gt;&amp;#034;Grayscale&amp;#034;}]/@masks}&#xD;
    ]&#xD;
    &#xD;
       &#xD;
    (* ::Section:: *)&#xD;
    (*Training UNet*)&#xD;
        &#xD;
    trainNetwithValidation[net_,dataset_,labeldataset_,validationset_,labelvalidationset_, batchsize_: 8, maxtrainRounds_: 100]:=Module[{},&#xD;
     SetDirectory[NotebookDirectory[]];&#xD;
     NetTrain[net, dataset-&amp;gt;labeldataset,All, ValidationSet -&amp;gt; Thread[validationset-&amp;gt; labelvalidationset],&#xD;
     BatchSize-&amp;gt;batchsize,MaxTrainingRounds-&amp;gt;maxtrainRounds, TargetDevice-&amp;gt;&amp;#034;GPU&amp;#034;,&#xD;
     TrainingProgressCheckpointing-&amp;gt;{&amp;#034;Directory&amp;#034;,&amp;#034;results&amp;#034;,&amp;#034;Interval&amp;#034;-&amp;gt;Quantity[5,&amp;#034;Rounds&amp;#034;]}]&#xD;
    ];&#xD;
        &#xD;
    trainNet[net_,dataset_,labeldataset_, batchsize_:8, maxtrainRounds_: 10]:=Module[{},&#xD;
     SetDirectory[NotebookDirectory[]];&#xD;
     NetTrain[net, dataset-&amp;gt;labeldataset,All,BatchSize-&amp;gt;batchsize,MaxTrainingRounds-&amp;gt;maxtrainRounds, TargetDevice-&amp;gt;&amp;#034;GPU&amp;#034;,&#xD;
     TrainingProgressCheckpointing-&amp;gt;{&amp;#034;Directory&amp;#034;,&amp;#034;results&amp;#034;,&amp;#034;Interval&amp;#034;-&amp;gt; Quantity[5,&amp;#034;Rounds&amp;#034;]}]&#xD;
    ];&#xD;
        &#xD;
    (* ::Section:: *)&#xD;
    (*Measure Accuracy*)&#xD;
        &#xD;
    measureModelAccuracy[net_,data_,groundTruth_]:= Module[{acc},&#xD;
    acc =Table[{i, 1.0 - HammingDistance[N@Round@Flatten@net[data[[i]],TargetDevice-&amp;gt;&amp;#034;GPU&amp;#034;],&#xD;
     Flatten@groundTruth[[i]]]/(160*160)},{i,Length@data}&#xD;
    ];&#xD;
    {Mean@Part[acc,All,2],TableForm@acc}&#xD;
    ];&#xD;
        &#xD;
    (* ::Section:: *)&#xD;
    (*Miscellaneous*)&#xD;
    &#xD;
    saveNeuralNet[net_]:= Module[{dir = NotebookDirectory[]},&#xD;
     Export[dir&amp;lt;&amp;gt;&amp;#034;unet.wlnet&amp;#034;,net]]/; Head[net]=== NetGraph;&#xD;
    &#xD;
    &#xD;
    saveInputs[data_,labels_,opt:(&amp;#034;data&amp;#034;|&amp;#034;validation&amp;#034;)]:=Module[{},&#xD;
     SetDirectory[NotebookDirectory[]];&#xD;
     Switch[opt,&amp;#034;data&amp;#034;,&#xD;
      Export[&amp;#034;X.mx&amp;#034;,data];Export[&amp;#034;Y.mx&amp;#034;,labels],&#xD;
      &amp;#034;validation&amp;#034;,&#xD;
      Export[&amp;#034;Xval.mx&amp;#034;,data];Export[&amp;#034;Yval.mx&amp;#034;,labels]&#xD;
     ]&#xD;
    ]&#xD;
        &#xD;
    EndPackage[];&#xD;
&#xD;
The above code can also be found in the repository @ [Wolfram-MXNET GITHUB][3]&#xD;
&#xD;
I trained my network over my laptop GPU (Nvidia GTX 1050) by feeding an augmented data (a set of 300 images constructed from a small dataset) . The training was done in under 3 minutes !. The accuracy (computed as the Hamming Distance between two vectors) of the generated binary masks with respect to the ground truth (unseen data) for a set of 90 images was 98.55 %. And with this a task that previously required me to painstakingly trace the contour of the gastruloids manually can now be performed in a matter of milliseconds. All the saved time and perspiration to be utilized somewhere else?&#xD;
&#xD;
![enter image description here][4]&#xD;
&#xD;
Below is the results obtained by applying our trained net on one input:&#xD;
&#xD;
![enter image description here][5]&#xD;
&#xD;
The interesting aspect for me regarding the network was that despite my gastruloids being highly dynamic (changing shape over time) I never had to explicity state it to the network. All the necessary features were learned from the limited number of images that I trained my network with. This is the beauty of the neural network.&#xD;
&#xD;
![enter image description here][6]&#xD;
&#xD;
Finally the output of the net as applied on a number of unseen images:&#xD;
&#xD;
![enter image description here][7]&#xD;
&#xD;
Note: I have a python MXNET version of UNET  @  [python mxnet GITHUB][8]&#xD;
&#xD;
The wolfram version of UNET however seems to outperform the python version even though it also utilizes MXNET at the back-end for implementing neural networks. It should not come as a surprise because my guess is that the people at Wolfram Research may have done internal optimizations on top of the library&#xD;
&#xD;
&#xD;
  [1]: http://community.wolfram.com//c/portal/getImageAttachment?filename=gastruloid.png&amp;amp;userId=942204&#xD;
  [2]: http://community.wolfram.com//c/portal/getImageAttachment?filename=u-net-architecture-initial-authors-implementation.png&amp;amp;userId=942204&#xD;
  [3]: https://github.com/alihashmiii/UNet-Segmentation-Wolfram&#xD;
  [4]: http://community.wolfram.com//c/portal/getImageAttachment?filename=img1.png&amp;amp;userId=942204&#xD;
  [5]: http://community.wolfram.com//c/portal/getImageAttachment?filename=img2.png&amp;amp;userId=942204&#xD;
  [6]: http://community.wolfram.com//c/portal/getImageAttachment?filename=img3.png&amp;amp;userId=942204&#xD;
  [7]: http://community.wolfram.com//c/portal/getImageAttachment?filename=img4.png&amp;amp;userId=942204&#xD;
  [8]: https://github.com/alihashmiii/blobsegmentation</description>
    <dc:creator>Ali Hashmi</dc:creator>
    <dc:date>2018-05-17T15:06:45Z</dc:date>
  </item>
  <item rdf:about="https://community.wolfram.com/groups/-/m/t/1646303">
    <title>UNET: neural network for 2D &amp;amp; 3D image segmentation w/ medical examples</title>
    <link>https://community.wolfram.com/groups/-/m/t/1646303</link>
    <description># UNET [![DOI](https://zenodo.org/badge/137186334.svg)](https://zenodo.org/badge/latestdoi/137186334) [![contributions welcome](https://img.shields.io/badge/contributions-welcome-brightgreen.svg?style=flat)](https://github.com/dwyl/esta/issues)&#xD;
&#xD;
&#xD;
----------&#xD;
&#xD;
![Automated 3D muscle segmentation using UNET / RESNET using DIXON MRI data][17]&#xD;
&#xD;
&#xD;
A package to generate and train a UNET deep convolutional network for 2D and 3D image segmentation.&#xD;
&#xD;
Some code was based on [work][1] by [@Ali Hashmi][at0], which was also dicussed in [this post][2] &#xD;
The full version of the toolbox can be found on my [github page][3].&#xD;
&#xD;
* [Information](#information)&#xD;
* [Install toolbox](#install-toolbox)&#xD;
* [Using the toolbox](#using-the-toolbox)&#xD;
* [Functionality](#functionality)&#xD;
* [Visualization](#visualization)&#xD;
* [Example](#example)&#xD;
&#xD;
## Information&#xD;
&#xD;
UNET is developed for [Mathematica](https://www.wolfram.com/mathematica/).&#xD;
It contains the following toolboxes:&#xD;
&#xD;
- UnetCore&#xD;
- UnetSupport&#xD;
&#xD;
Documentation of all functions and their options is fully integrated in the Mathematica documentation.&#xD;
The toolbox always works within the latest version of Mathematica and does not support any backward compatibility.&#xD;
&#xD;
All code and documentation is maintained and uploaded to github using [Workbench](https://www.wolfram.com/workbench/).&#xD;
&#xD;
## Install toolbox&#xD;
&#xD;
Install the toolbox in the Mathematica UserBaseDirectory &amp;gt; Applications.&#xD;
&#xD;
	FileNameJoin[{$UserBaseDirectory, &amp;#034;Applications&amp;#034;}]&#xD;
  &#xD;
## Using the toolbox&#xD;
&#xD;
The toolbox can be loaded by using &amp;lt;&amp;lt;UNET`&#xD;
&#xD;
The notbook ``UNET.nb`` shows examples of how to use the toolbox on artificially generated 2D data. &#xD;
There are also examples how to visualize the layer of your trained network and how to visualize the training itself. &#xD;
&#xD;
## Functionality&#xD;
&#xD;
The network supports multi channel inputs and multi class segmentation.&#xD;
&#xD;
* UNET generates a UNET convolutional network.  &#xD;
    * 2D UNET  &#xD;
![UNET 2D][4]&#xD;
    * 3D UNET  &#xD;
![UNET 3D][5]&#xD;
&#xD;
* Loss Layers: Training the data is done using three loss layers: a SoftDiceLossLayer, BrierLossLayer and a CrossEntropyLossLayer.  &#xD;
![SoftDiceLossLayer, BrierLossLayer and a CrossEntropyLossLayer][6]&#xD;
&#xD;
* Convolution Blocks: The toobox contains five different convolution blocks that build up the network: [UNET][7], UResNet, [RestNet][8], UDenseNet, [DensNet][9].  &#xD;
![Convolution blocks][10]&#xD;
&#xD;
* SplitTrainData splits the data and labels into training, validation and test data.  &#xD;
![split train Data][11]&#xD;
&#xD;
* TrainUNET trains the network.  &#xD;
![Train UNET][12]&#xD;
&#xD;
## Visualization&#xD;
&#xD;
* Visualize the network and results.  &#xD;
    * Visualize the features of the layers.  &#xD;
![Visualize layer features][13]&#xD;
    * Visualize the results.  &#xD;
![Visualize the results][14]&#xD;
    * Animate the training process.  &#xD;
![UNET 2D animation][15]  &#xD;
![UNET 3D animation][16]&#xD;
&#xD;
## Example&#xD;
&#xD;
* Example: 3D segmentation of lower legg muscles using MRI data.  &#xD;
&#xD;
![Automated 3D muscle segmentation using UNET / RESNET using DIXON MRI data][17]&#xD;
&#xD;
&#xD;
  [1]: https://github.com/alihashmiii/UNet-Segmentation-Wolfram&#xD;
  [2]: https://community.wolfram.com/groups/-/m/t/1341081?p_p_auth=w8PIeeiA&#xD;
  [3]: https://github.com/mfroeling&#xD;
  [4]: https://community.wolfram.com//c/portal/getImageAttachment?filename=UNET2D.PNG&amp;amp;userId=1332602&#xD;
  [5]: https://community.wolfram.com//c/portal/getImageAttachment?filename=UNET3D.PNG&amp;amp;userId=1332602&#xD;
  [6]: https://community.wolfram.com//c/portal/getImageAttachment?filename=Loss.PNG&amp;amp;userId=1332602&#xD;
  [7]: https://arxiv.org/abs/1505.04597&#xD;
  [8]: https://arxiv.org/abs/1512.03385&#xD;
  [9]: https://arxiv.org/abs/1608.06993&#xD;
  [10]: https://community.wolfram.com//c/portal/getImageAttachment?filename=convblocks.PNG&amp;amp;userId=1332602&#xD;
  [11]: https://community.wolfram.com//c/portal/getImageAttachment?filename=Split.PNG&amp;amp;userId=1332602&#xD;
  [12]: https://community.wolfram.com//c/portal/getImageAttachment?filename=Train.PNG&amp;amp;userId=1332602&#xD;
  [13]: https://community.wolfram.com//c/portal/getImageAttachment?filename=Visualize1.PNG&amp;amp;userId=1332602&#xD;
  [14]: https://community.wolfram.com//c/portal/getImageAttachment?filename=Visualize2.PNG&amp;amp;userId=1332602&#xD;
  [15]: https://community.wolfram.com//c/portal/getImageAttachment?filename=amin0-v2.gif&amp;amp;userId=1332602&#xD;
  [16]: https://community.wolfram.com//c/portal/getImageAttachment?filename=amin4-v2.gif&amp;amp;userId=1332602&#xD;
  [17]: https://community.wolfram.com//c/portal/getImageAttachment?filename=Muscle_Segmentation.jpg&amp;amp;userId=1332602&#xD;
&#xD;
 [at0]: https://community.wolfram.com/web/alihashmi87</description>
    <dc:creator>Martijn Froeling</dc:creator>
    <dc:date>2019-04-03T20:01:26Z</dc:date>
  </item>
  <item rdf:about="https://community.wolfram.com/groups/-/m/t/1843550">
    <title>Mandelbrot Set on Neural Network</title>
    <link>https://community.wolfram.com/groups/-/m/t/1843550</link>
    <description>*MODERATOR NOTE: a submission to computations art contest, see more:* https://wolfr.am/CompArt-22&#xD;
&#xD;
----------&#xD;
&#xD;
Showing Abs and Arg fields of Mandelbrot set under 200 iterations&#xD;
&#xD;
![Mandelbrot_wallpaper.png][1]&#xD;
&#xD;
---&#xD;
&#xD;
Showing Abs field of Mandelbrot set under 9 iterations&#xD;
&#xD;
![9_iteration_abs.png][2]&#xD;
&#xD;
---&#xD;
&#xD;
Showing Re vs. Im complex mapping of Mandelbrot set under 200 iterations&#xD;
&#xD;
![ReIm_Complex_map.png][3]&#xD;
&#xD;
---&#xD;
&#xD;
Mandelbrot Set on Neural Network&#xD;
===========================================&#xD;
&#xD;
[The MXNet-based neural network framework](http://reference.wolfram.com/language/guide/NeuralNetworks.html) has been introduced to Wolfram Language since version 11. It is mostly designed for deep learning. However if we think about it, neural network is merely another fancy way to implement a certain program. As more and more functions are supported, it is now possible for us to &amp;#034;compile&amp;#034; general numerical program to neural network, which essentially gives us an interface to GPGPU parallel ability without the hassle of low-level coding.&#xD;
&#xD;
Inspired by [Brian](https://community.wolfram.com/web/tl2854)&amp;#039;s [recent post on MathCompile](https://community.wolfram.com/groups/-/m/t/1830592), we demonstrate in this post how to implement a neural network to compute the Mandelbrot set.&#xD;
&#xD;
## Utilities&#xD;
&#xD;
As usual here is the code dump of some helper functions. Readers can evaluate then safely skip this section.&#xD;
&#xD;
### code dump of helper functions&#xD;
&#xD;
```&#xD;
ClearAll[pipe, branch]&#xD;
pipe   = RightComposition;&#xD;
branch = Through@*{##} &amp;amp;;&#xD;
```&#xD;
```&#xD;
Needs[&amp;#034;NeuralNetworks`&amp;#034;]&#xD;
```&#xD;
```&#xD;
Clear[netInputPortSort]&#xD;
netInputPortSort[inPortLst_List] := Function[origNet, netInputPortSort[origNet, inPortLst]]&#xD;
netInputPortSort[origNet_NetGraph, inPortLst_List] :=&#xD;
 Block[{NetGraph = Inactive[NetGraph], fullnet, net},&#xD;
           fullnet         = origNet&#xD;
           ; net           = fullnet[[1]]&#xD;
           ; net[&amp;#034;Inputs&amp;#034;] = AssociationThread[Rule[inPortLst, inPortLst /. net[&amp;#034;Inputs&amp;#034;]]]&#xD;
           ; ReplacePart[fullnet, 1 -&amp;gt; net]&#xD;
      ] // Activate&#xD;
```&#xD;
&#xD;
---&#xD;
&#xD;
# Basic concept&#xD;
&#xD;
The center of the Mandelbrot set computation is a simple iteration:&#xD;
&#xD;
$$\left\{&#xD;
\begin{align}&#xD;
 z_n &amp;amp;= c+z_{n-1}^2 \\&#xD;
 z_0 &amp;amp;= 0&#xD;
\end{align}&#xD;
\right.$$&#xD;
&#xD;
Under simple iteration it leads to the Mandelbrot set.&#xD;
&#xD;
```&#xD;
Block[{region, c, faclets}&#xD;
         ,&#xD;
         (* random-points as different c for iteration: *)&#xD;
         region = Disk[{-.5, 0}, 2] // DiscretizeGraphics // DiscretizeRegion[#, MaxCellMeasure -&amp;gt; .0001] &amp;amp;&#xD;
         ; faclets = MeshCells[region, 2][[;; , 1]]&#xD;
         ; c = MeshCoordinates[region].{1, I}&#xD;
         ;(* The iteration taking place simultaneously for all c, nested 21 steps: *)&#xD;
         Nest[Function[z, z^2 + c], 0, 21] //&#xD;
              (* Visualizing the result: *)&#xD;
              pipe[&#xD;
                      pipe[(* Regularizing the norm for a clear visualization: *)&#xD;
                           Abs, HistogramTransform, Rescale, (1 - #)^2 &amp;amp;]&#xD;
                      , Append[ReIm[c]\[Transpose], #]\[Transpose] &amp;amp;&#xD;
                      , Graphics3D[&#xD;
                                    GraphicsComplex[#, {EdgeForm[], Polygon@faclets}]&#xD;
                                    , Boxed -&amp;gt; False, SphericalRegion -&amp;gt; True, RotationAction -&amp;gt; &amp;#034;Fit&amp;#034;&#xD;
                                    , ViewPoint -&amp;gt; {1, -2.4, 2.4}, ViewVertical -&amp;gt; {0, 0, 1}&#xD;
                                  ] &amp;amp;&#xD;
                  ]&#xD;
     ]&#xD;
```&#xD;
&#xD;
![3D mesh of Mandelbrot set][4]&#xD;
&#xD;
Using the built-in [`MandelbrotSetPlot`](http://reference.wolfram.com/language/ref/MandelbrotSetPlot.html) function, it&amp;#039;s straightforward to plot the traditional Mandelbrot set visualization:&#xD;
&#xD;
```&#xD;
MandelbrotSetPlot[{-2.5 - 2 I, 1.5 + 2 I}]&#xD;
```&#xD;
&#xD;
![MandelbrotSetPlot][5]&#xD;
&#xD;
With some test we can notice that, for fixed `MaxIterations`, the relationship between computing time of `MandelbrotSetPlot` and `ImageResolution` follows a power law.&#xD;
&#xD;
```&#xD;
builtInTimeTest = {#, AbsoluteTiming[MandelbrotSetPlot[{-2.5 - 2 I, 1.5 + 2 I}, MaxIterations -&amp;gt; 100, ImageResolution -&amp;gt; #];][[1]]} &amp;amp; /@ Range[101, 4001, 100]&#xD;
&#xD;
NonlinearModelFit[builtInTimeTest, a r^k, {a, k}, r][r] //&#xD;
  LogLogPlot[#, {r, 400, 5000}, PlotStyle -&amp;gt; Directive[Red, AbsoluteThickness[2]], Frame -&amp;gt; True, FrameTicks -&amp;gt; All] &amp;amp; //&#xD;
  Show[{#&#xD;
        , ListLogLogPlot[builtInTimeTest, PlotMarkers -&amp;gt; &amp;#034;OpenMarkers&amp;#034;, PlotRange -&amp;gt; All]&#xD;
        }, FrameLabel -&amp;gt; {&amp;#034;ImageResolution&amp;#034;, &amp;#034;AbsoluteTiming&amp;#034;}] &amp;amp;&#xD;
```&#xD;
&#xD;
![time benchmark of MandelbrotSetPlot][6]&#xD;
&#xD;
This is a scenario where parallel computation might make a difference.&#xD;
&#xD;
---&#xD;
&#xD;
# Mandelbrot set on neural network -- A naïve attempt&#xD;
&#xD;
## The implementation&#xD;
&#xD;
### Iteration core net&#xD;
&#xD;
Neural network (short for **_NN_**) doesn&amp;#039;t support complex number (yet). Aside from that, the iteration formula is simple enough for [`ThreadingLayer`](http://reference.wolfram.com/language/ref/ThreadingLayer.html):&#xD;
&#xD;
```&#xD;
iterNet = Module[{c = cX + cY I, z = x + y I},&#xD;
  z^2 + c // pipe[&#xD;
                    ReIm, ComplexExpand, Echo[#, &amp;#034;{Re[\!\(\*SuperscriptBox[\(z\), \(2\)]\)+c], Im[\!\(\*SuperscriptBox[\(z\), \(2\)]\)+c]}:&amp;#034;] &amp;amp;&#xD;
                    , Map@pipe[&#xD;
                                 Inactive[Function][{cX, cY, x, y}, #] &amp;amp;&#xD;
                                 , Activate&#xD;
                                 , ThreadingLayer&#xD;
                              ]&#xD;
                    , Inactive[NetGraph][#&#xD;
                                            , {&#xD;
                                                   (NetPort /@ StringSplit[&amp;#034;cX,cY,x,y&amp;#034;, &amp;#034;,&amp;#034;]) -&amp;gt; # &amp;amp; /@ {1, 2}&#xD;
                                                   , 1 -&amp;gt; NetPort[&amp;#034;x&amp;#034;], 2 -&amp;gt; NetPort[&amp;#034;y&amp;#034;]&#xD;
                                              }&#xD;
                                        ] &amp;amp;&#xD;
                    , Activate&#xD;
                 ]&#xD;
  ]&#xD;
```&#xD;
&#xD;
![iterNet][7]&#xD;
&#xD;
It&amp;#039;s very easy to perform the iteration with the help of [`Nest`](http://reference.wolfram.com/language/ref/Nest.html) / [`NestList`](http://reference.wolfram.com/language/ref/NestList.html).&#xD;
&#xD;
```&#xD;
Block[{region, c, xyInit, result}&#xD;
         ,&#xD;
         (* random-points as different c for iteration: *)&#xD;
         region = Disk[{0, 0}, .5] // DiscretizeGraphics // DiscretizeRegion[#, MaxCellMeasure -&amp;gt; .01] &amp;amp;&#xD;
         ; c = MeshCoordinates[region].{1, I} // ReIm&#xD;
         ; c = AssociationThread[StringSplit[&amp;#034;cX,cY&amp;#034;, &amp;#034;,&amp;#034;], c\[Transpose]]&#xD;
         ; xyInit = AssociationThread[StringSplit[&amp;#034;x,y&amp;#034;, &amp;#034;,&amp;#034;], 0*Values[c]]&#xD;
         ; result = NestList[&#xD;
                                pipe[&#xD;
                                      Map[Clip[#, {-2, 2}] &amp;amp;]&#xD;
                                      , Join[c, #] &amp;amp;&#xD;
                                      , iterNet&#xD;
                                    ]&#xD;
                                , xyInit, 20&#xD;
                            ]&#xD;
         ; result //&#xD;
             pipe[&#xD;
                     Values, Rest, Map@Transpose&#xD;
                     , Transpose&#xD;
                     , MapThread[{#2, BSplineCurve@#1} &amp;amp;, {#, # // Length // Range // N // Rescale // Map[ColorData[&amp;#034;Rainbow&amp;#034;]]}] &amp;amp;&#xD;
                     , Graphics[#, Frame -&amp;gt; True, FrameTicks -&amp;gt; All, PlotRange -&amp;gt; {GoldenRatio {-1, 1}, {-1, 1}}, PlotRangeClipping -&amp;gt; True] &amp;amp;&#xD;
                 ]&#xD;
     ]&#xD;
```&#xD;
&#xD;
![Nest on iterNet][8]&#xD;
&#xD;
### Nest net&#xD;
&#xD;
Now we have the core net representing the iteration formula, we need to mimic the functionality of `Nest[f, expr, n]` fully on a neural network.&#xD;
&#xD;
The go-to function is of course [`NetNestOperator`](https://reference.wolfram.com/language/ref/NetNestOperator.html). However in our case, the same $c$ is used repeatedly for all iterations, so we&amp;#039;d like to pass it directly to each iteration. Thus, we do it with the following customized `NetNestPartialOperator` function:&#xD;
&#xD;
```&#xD;
ClearAll[NetNestPartialOperator]&#xD;
NetNestPartialOperator[net_, staticPorts_List, nestPort_, iterNum_Integer] :=&#xD;
 Module[{pIdx, netIdx, staticpath, nestpath},&#xD;
  netIdx = Range[iterNum]&#xD;
  ; pIdx = AssociationThread[staticPorts, staticPorts // Length // Range // Map[ToString]]&#xD;
  ; staticpath = Function[p, NetPort[&amp;#034;static&amp;#034; &amp;lt;&amp;gt; pIdx[p]] -&amp;gt; (NetPort[#, p] &amp;amp; /@ netIdx)] /@ staticPorts&#xD;
  ; nestpath = Thread[Flatten[{NetPort[&amp;#034;nest&amp;#034;], netIdx // Most}] -&amp;gt; (NetPort[#, nestPort] &amp;amp; /@ netIdx)]&#xD;
  ; Inactive[NetGraph][ConstantArray[net, iterNum], {staticpath, nestpath} // Flatten] //&#xD;
       Activate // &#xD;
       netInputPortSort[Flatten[{&amp;#034;nest&amp;#034;, &amp;#034;static&amp;#034; &amp;lt;&amp;gt; # &amp;amp; /@ Values[pIdx]}]]&#xD;
  ]&#xD;
```&#xD;
&#xD;
Basically our `NetNestPartialOperator` takes a [`net_NetGraph`](https://reference.wolfram.com/language/ref/NetGraph.html) as the 1st argument. One of `net`&amp;#039;s input ports, i.e. `nestPort`, is going to be nested across iterations; other input ports (i.e. `staticPorts`) will be feed in constant/non-nested values.&#xD;
&#xD;
Here is a simple example realizing a 5 steps nest iteration `Nest[Function[c,a+b+c],c0,5]`:&#xD;
&#xD;
```&#xD;
Module[{coreNet, nestNet}&#xD;
           , coreNet = NetGraph[{ThreadingLayer[#1+#2+#3&amp;amp;]}, {{NetPort[&amp;#034;a&amp;#034;],NetPort[&amp;#034;b&amp;#034;],NetPort[&amp;#034;c&amp;#034;]}-&amp;gt;1},&amp;#034;a&amp;#034;-&amp;gt;&amp;#034;Real&amp;#034;,&amp;#034;b&amp;#034;-&amp;gt;&amp;#034;Real&amp;#034;,&amp;#034;c&amp;#034;-&amp;gt;&amp;#034;Real&amp;#034;]&#xD;
           ; nestNet = NetNestPartialOperator[coreNet, {&amp;#034;a&amp;#034;, &amp;#034;b&amp;#034;}, &amp;#034;c&amp;#034;, 5]&#xD;
           ; {&#xD;
               {&amp;#034;coreNet&amp;#034;, &amp;#034;nestNet&amp;#034;}&#xD;
               , Quiet[&#xD;
                         NetInformation[#, &amp;#034;MXNetNodeGraph&amp;#034;] // Graph[#, VertexSize -&amp;gt; 0.2, VertexLabels -&amp;gt; &amp;#034;Name&amp;#034;] &amp;amp;&#xD;
                      ] &amp;amp; /@ {coreNet, nestNet}&#xD;
             }\[Transpose] // &#xD;
             Grid[#, Background -&amp;gt; {{GrayLevel[.9], None}, None}, Frame -&amp;gt; All, FrameStyle -&amp;gt; Black] &amp;amp;&#xD;
      ]&#xD;
```&#xD;
&#xD;
![NetNestPartialOperator example][9]&#xD;
&#xD;
### The Mandelbrot net&#xD;
&#xD;
In order to construct a net suitable for `NetNestPartialOperator`, we merge the real and imaginary ports in `iterNet` into a single &amp;#034;complex&amp;#034; port.&#xD;
&#xD;
```&#xD;
zNet = NetGraph[{ReplicateLayer[1], ReplicateLayer[1], CatenateLayer[]}, {NetPort[&amp;#034;1&amp;#034;] -&amp;gt; 1, NetPort[&amp;#034;2&amp;#034;] -&amp;gt; 2, {1, 2} -&amp;gt; 3}];&#xD;
&#xD;
nestcoreNet = NetGraph[&#xD;
                        {PartLayer[1], PartLayer[2], iterNet, zNet}&#xD;
                        , {&#xD;
                               (NetPort[#] -&amp;gt; NetPort[3, #]) &amp;amp; /@ StringSplit[&amp;#034;cX,cY&amp;#034;, &amp;#034;,&amp;#034;]&#xD;
                             , NetPort[&amp;#034;z&amp;#034;] -&amp;gt; {1, 2}&#xD;
                             , {{1, 2}, StringSplit[&amp;#034;x,y&amp;#034;, &amp;#034;,&amp;#034;]} // MapThread[(#1 -&amp;gt; NetPort[3, #2]) &amp;amp;]&#xD;
                             , {StringSplit[&amp;#034;x,y&amp;#034;, &amp;#034;,&amp;#034;], StringSplit[&amp;#034;1,2&amp;#034;, &amp;#034;,&amp;#034;]} // MapThread[(NetPort[3, #1] -&amp;gt; NetPort[4, #2]) &amp;amp;]&#xD;
                          }&#xD;
                      ]&#xD;
```&#xD;
&#xD;
![nestcoreNet][10]&#xD;
&#xD;
Thus a full net computing the Mandelbrot set is constructed as follows:&#xD;
&#xD;
```&#xD;
ClearAll[mandelbrot]&#xD;
mandelbrot[iterNum_Integer?Positive] :=&#xD;
     NetGraph[{&#xD;
                  zNet&#xD;
                , ElementwiseLayer[0 # &amp;amp;]&#xD;
                , NetNestPartialOperator[nestcoreNet, StringSplit[&amp;#034;cX,cY&amp;#034;, &amp;#034;,&amp;#034;], &amp;#034;z&amp;#034;, iterNum]&#xD;
              }, {&#xD;
                  {NetPort[&amp;#034;cX&amp;#034;], NetPort[&amp;#034;cY&amp;#034;]} -&amp;gt; 1 -&amp;gt; 2&#xD;
                , {2, NetPort[&amp;#034;cX&amp;#034;], NetPort[&amp;#034;cY&amp;#034;]} -&amp;gt; 3&#xD;
              }&#xD;
             ]&#xD;
```&#xD;
&#xD;
## Results&#xD;
&#xD;
We showcase our `mandelbrot` net with 9 iteration steps over the complex region ${-2-1.2I,1+1.2I}$, with a image resolution $401 \times 501$. The network is executed on a GPU (NVIDIA GeForce GTX 1050 Ti) with [`&amp;#034;Real64&amp;#034;`](https://reference.wolfram.com/language/ref/NetGraph.html#1010560149) precision.&#xD;
&#xD;
```&#xD;
mandelbrotF = mandelbrot[9];&#xD;
```&#xD;
```&#xD;
result =&#xD;
  Module[{region = {-2 - 1.2 I, 1 + 1.2 I}, resol = 501, aspr},&#xD;
         region = region // ReIm // Transpose&#xD;
         ; aspr = region.{-1, 1} // Reverse // Apply[Divide]&#xD;
         ; resol = resol {1, aspr} // Round&#xD;
         ; {resol, region} //&#xD;
             pipe[&#xD;
                   MapThread[Rescale[Range[#1] // N // Rescale, {0, 1}, #2] &amp;amp;]&#xD;
                   , Tuples&#xD;
                   , AssociationThread[{&amp;#034;cX&amp;#034;, &amp;#034;cY&amp;#034;}, #\[Transpose]] &amp;amp;&#xD;
                   , AbsoluteTiming[mandelbrotF[#, WorkingPrecision -&amp;gt; &amp;#034;Real64&amp;#034;, TargetDevice -&amp;gt; &amp;#034;GPU&amp;#034;]] &amp;amp;&#xD;
                   , pipe[&#xD;
                            branch[pipe[First, Quantity[#, &amp;#034;Seconds&amp;#034;] &amp;amp;, Echo[#, &amp;#034;Computing time on NN:&amp;#034;] &amp;amp;], Last]&#xD;
                            , Last]&#xD;
                   , Developer`ToPackedArray&#xD;
                   , ArrayReshape[#, {2, Sequence @@ resol}] &amp;amp;&#xD;
                   , {1, I}.# &amp;amp;&#xD;
                   , Transpose, Reverse&#xD;
                 ]&#xD;
        ];&#xD;
&#xD;
(* Computing time on NN: 3.08505 s *)&#xD;
```&#xD;
```&#xD;
result // Dimensions&#xD;
(* {401, 501} *)&#xD;
```&#xD;
```&#xD;
result //&#xD;
   pipe[&#xD;
         branch[&#xD;
                 pipe[ Abs&#xD;
                     , pipe[&#xD;
                             branch[Flatten /* HistogramTransform, Dimensions /* Last]&#xD;
                           , Apply@Partition&#xD;
                           ]&#xD;
                     , Rescale, (1 - #)^5 &amp;amp;&#xD;
                     ]&#xD;
               , pipe[Arg, Sin, Rescale]&#xD;
               ]&#xD;
       , Map @ pipe[&#xD;
                     Image[#, ImageSize -&amp;gt; Length[#]] &amp;amp;&#xD;
                   , Colorize[#, ColorFunction -&amp;gt; &amp;#034;DarkColorFractalGradient&amp;#034;] &amp;amp;&#xD;
                   ]&#xD;
       ]&#xD;
```&#xD;
&#xD;
![naive result][11]&#xD;
&#xD;
Note the highlighted [periodic bulbs and Mandelbrot dendritic islands](https://dhushara.com/DarkHeart/DarkHeart.htm) in the left image, and the pattern approximately following the [external rays](https://en.wikipedia.org/wiki/External_ray) of the set in the right image.&#xD;
&#xD;
As a comparison, here is the result from the same region, iteration steps and resolution using the built-in `MandelbrotSetPlot` function.&#xD;
&#xD;
```&#xD;
AbsoluteTiming[&#xD;
                MandelbrotSetPlot[{-2 - 1.2 I, 1 + 1.2 I}, MaxIterations -&amp;gt; 9, ImageResolution -&amp;gt; 501]&#xD;
              ] //&#xD;
     pipe[&#xD;
           branch[pipe[First, Quantity[#, &amp;#034;Seconds&amp;#034;] &amp;amp;, Echo[#, &amp;#034;Computing time:&amp;#034;] &amp;amp;], Last], Last&#xD;
         , #[[1, 1]] &amp;amp;, Reverse, Image[#, ImageSize -&amp;gt; Dimensions[#][[1]]] &amp;amp;&#xD;
         ]&#xD;
&#xD;
(* Computing time: 0.187943 s *)&#xD;
```&#xD;
&#xD;
![MandelbrotSetPlotOver(-2-1.2I,1+1.2I)][12]&#xD;
&#xD;
Clearly at this resolution scale, `MandelbrotSetPlot` is much faster than our neural-net function. But at a much larger resolution our function will eventually win.&#xD;
&#xD;
```&#xD;
myMandelbrotSetPlotTiming[resolution_Integer] := &#xD;
 Module[ {region = {-2 - 1.2 I, 1 + 1.2 I}, aspr, resol}&#xD;
       , region = region // ReIm // Transpose&#xD;
       ; aspr   = region.{-1, 1} // Reverse // Apply[Divide]&#xD;
       ; resol  = resolution {1, aspr} // Round&#xD;
       ; {resol, region} //&#xD;
            pipe[&#xD;
                  MapThread[Rescale[Range[#1] // N // Rescale, {0, 1}, #2] &amp;amp;]&#xD;
                , Tuples&#xD;
                , AssociationThread[{&amp;#034;cX&amp;#034;, &amp;#034;cY&amp;#034;}, #\[Transpose]] &amp;amp;&#xD;
                , AbsoluteTiming[mandelbrotF[#, WorkingPrecision -&amp;gt; &amp;#034;Real64&amp;#034;, TargetDevice -&amp;gt; &amp;#034;GPU&amp;#034;];][[1]] &amp;amp;&#xD;
                , {resolution, #} &amp;amp;&#xD;
                ]&#xD;
       ]&#xD;
&#xD;
myTimeTest = myMandelbrotSetPlotTiming /@ Range[101, 4001, 100];&#xD;
&#xD;
NonlinearModelFit[myTimeTest, a r^k, {a, k}, r][r] //&#xD;
  LogLogPlot[#, {r, 400, 5000}, PlotStyle -&amp;gt; Directive[Purple, AbsoluteThickness[2]], Frame -&amp;gt; True, FrameTicks -&amp;gt; All] &amp;amp; //&#xD;
 Show[ {&#xD;
         #&#xD;
       , ListLogLogPlot[myTimeTest, PlotMarkers -&amp;gt; Graphics[{FaceForm[White], EdgeForm[{Orange, AbsoluteThickness[1]}], Polygon[CirclePoints[4]]}, ImageSize -&amp;gt; 7], PlotRange -&amp;gt; All]&#xD;
       }&#xD;
     , FrameLabel -&amp;gt; {&amp;#034;ImageResolution&amp;#034;, &amp;#034;AbsoluteTiming&amp;#034;}&#xD;
     ] &amp;amp;&#xD;
```&#xD;
&#xD;
![time benchmark of NN based mandelbrot][13]&#xD;
&#xD;
Comparing with previous benchmark result of `MandelbrotSetPlot`, we can see our NN-based function has an advantage when the image resolution is large enough.&#xD;
&#xD;
![time bench comparison][14]&#xD;
&#xD;
---&#xD;
&#xD;
# Mandelbrot set on neural network -- Avoid overflow&#xD;
&#xD;
Careful readers will find that for larger iteration steps and/or a larger computing region, our naïvely implemented `mandelbrot` will lead to overflow. That is of course due to the $c$ values leading to divergency. One simple way to avoid this overflow is to constrain the nested $z$ to a bounded region at every iteration step.&#xD;
&#xD;
## The implementation&#xD;
&#xD;
### A constrained iteration core net&#xD;
&#xD;
The simplest way to constrain the nested $z$ is to clip it into a rectangle region.&#xD;
&#xD;
```&#xD;
iterNet = Module[{c = cX + cY I, z = x + y I},&#xD;
  z^2 + c // pipe[&#xD;
                   ReIm, ComplexExpand, Echo[#, &amp;#034;{Re[\!\(\*SuperscriptBox[\(z\), \(2\)]\)+c], Im[\!\(\*SuperscriptBox[\(z\), \(2\)]\)+c]}:&amp;#034;] &amp;amp;&#xD;
                 , Map@pipe[&#xD;
(* The constraint: -&amp;gt; *)     Block[{escR = 3}, escR Clip[#/escR]] &amp;amp;&#xD;
                           , Inactive[Function][{cX, cY, x, y}, #] &amp;amp;&#xD;
                           , Activate&#xD;
                           , ThreadingLayer&#xD;
                           ]&#xD;
                 , Inactive[NetGraph][#&#xD;
                                         , {&#xD;
                                                (NetPort /@ StringSplit[&amp;#034;cX,cY,x,y&amp;#034;, &amp;#034;,&amp;#034;]) -&amp;gt; # &amp;amp; /@ {1, 2}&#xD;
                                                , 1 -&amp;gt; NetPort[&amp;#034;x&amp;#034;], 2 -&amp;gt; NetPort[&amp;#034;y&amp;#034;]&#xD;
                                           }&#xD;
                                     ] &amp;amp;&#xD;
                 , Activate&#xD;
                 ]&#xD;
  ]&#xD;
```&#xD;
&#xD;
### The Mandelbrot net&#xD;
&#xD;
Re-evaluating the rest of the code leads to our simply constrained `mandelbrotCons` function.&#xD;
&#xD;
```&#xD;
nestcoreNet = NetGraph[&#xD;
                        {PartLayer[1], PartLayer[2], iterNet, zNet}&#xD;
                      , {&#xD;
                          (NetPort[#] -&amp;gt; NetPort[3, #]) &amp;amp; /@ StringSplit[&amp;#034;cX,cY&amp;#034;, &amp;#034;,&amp;#034;]&#xD;
                        , NetPort[&amp;#034;z&amp;#034;] -&amp;gt; {1, 2}&#xD;
                        , {{1, 2}, StringSplit[&amp;#034;x,y&amp;#034;, &amp;#034;,&amp;#034;]} // MapThread[(#1 -&amp;gt; NetPort[3, #2]) &amp;amp;]&#xD;
                        , {StringSplit[&amp;#034;x,y&amp;#034;, &amp;#034;,&amp;#034;], StringSplit[&amp;#034;1,2&amp;#034;, &amp;#034;,&amp;#034;]} // MapThread[(NetPort[3, #1] -&amp;gt; NetPort[4, #2]) &amp;amp;]&#xD;
                        }&#xD;
                      ]&#xD;
```&#xD;
```&#xD;
ClearAll[mandelbrotCons]&#xD;
mandelbrotCons[iterNum_Integer?Positive] :=&#xD;
     NetGraph[{&#xD;
                zNet&#xD;
              , ElementwiseLayer[0 # &amp;amp;]&#xD;
              , NetNestPartialOperator[nestcoreNet, StringSplit[&amp;#034;cX,cY&amp;#034;, &amp;#034;,&amp;#034;], &amp;#034;z&amp;#034;, iterNum]&#xD;
              },&#xD;
              {&#xD;
                {NetPort[&amp;#034;cX&amp;#034;], NetPort[&amp;#034;cY&amp;#034;]} -&amp;gt; 1 -&amp;gt; 2&#xD;
              , {2, NetPort[&amp;#034;cX&amp;#034;], NetPort[&amp;#034;cY&amp;#034;]} -&amp;gt; 3&#xD;
              }&#xD;
             ]&#xD;
```&#xD;
&#xD;
## Results&#xD;
&#xD;
Now we can go for much larger iteration steps on a larger region.&#xD;
&#xD;
```&#xD;
mandelbrotConsF = mandelbrotCons[200];&#xD;
```&#xD;
```&#xD;
result =&#xD;
  Module[{region = {-3 - 2 I, 1 + 2 I}, resol = 1001, aspr},&#xD;
         region = region // ReIm // Transpose&#xD;
         ; aspr = region.{-1, 1} // Reverse // Apply[Divide]&#xD;
         ; resol = resol {1, aspr} // Round&#xD;
         ; {resol, region} //&#xD;
             pipe[&#xD;
                   MapThread[Rescale[Range[#1] // N // Rescale, {0, 1}, #2] &amp;amp;]&#xD;
                   , Tuples&#xD;
                   , AssociationThread[{&amp;#034;cX&amp;#034;, &amp;#034;cY&amp;#034;}, #\[Transpose]] &amp;amp;&#xD;
                   , AbsoluteTiming[mandelbrotConsF[#, WorkingPrecision -&amp;gt; &amp;#034;Real64&amp;#034;, TargetDevice -&amp;gt; &amp;#034;GPU&amp;#034;]] &amp;amp;&#xD;
                   , pipe[&#xD;
                            branch[pipe[First, Quantity[#, &amp;#034;Seconds&amp;#034;] &amp;amp;, Echo[#, &amp;#034;Computing time on NN:&amp;#034;] &amp;amp;], Last]&#xD;
                            , Last]&#xD;
                   , Developer`ToPackedArray&#xD;
                   , ArrayReshape[#, {2, Sequence @@ resol}] &amp;amp;&#xD;
                   , {1, I}.# &amp;amp;&#xD;
                   , Transpose, Reverse&#xD;
                 ]&#xD;
        ];&#xD;
&#xD;
(* Computing time on NN: 6.29684 s *)&#xD;
```&#xD;
```&#xD;
result // Dimensions&#xD;
(* {1001, 1001} *)&#xD;
```&#xD;
```&#xD;
result //&#xD;
   pipe[&#xD;
         branch[&#xD;
                 pipe[ Abs&#xD;
                     , pipe[&#xD;
                             branch[Flatten /* HistogramTransform, Dimensions /* Last]&#xD;
                           , Apply@Partition&#xD;
                           ]&#xD;
                     , Rescale, (1 - #)^5 &amp;amp;&#xD;
                     ]&#xD;
               , pipe[Arg, Sin, Rescale]&#xD;
               ]&#xD;
       , Map @ pipe[&#xD;
                     Image[#, ImageSize -&amp;gt; Length[#]] &amp;amp;&#xD;
                   , Colorize[#, ColorFunction -&amp;gt; &amp;#034;DarkColorFractalGradient&amp;#034;] &amp;amp;&#xD;
                   ]&#xD;
       ]&#xD;
```&#xD;
&#xD;
![constrained result][15]&#xD;
&#xD;
Or thresholding at 2 to get the classical Mandelbrot set.&#xD;
&#xD;
```&#xD;
result // Abs // UnitStep[2 - #] &amp;amp; // Image&#xD;
```&#xD;
&#xD;
![classical Mandelbrot 200][16]&#xD;
&#xD;
### Zoom-in&#xD;
&#xD;
For zoomed-in regions, this clipped version gives interesting results.&#xD;
&#xD;
```&#xD;
result =&#xD;
  Module[{region = {-0.65 + 0.47 I, -0.4 + 0.72 I}, resol = 1001, aspr},&#xD;
         region = region // ReIm // Transpose&#xD;
         ; aspr = region.{-1, 1} // Reverse // Apply[Divide]&#xD;
         ; resol = resol {1, aspr} // Round&#xD;
         ; {resol, region} //&#xD;
             pipe[&#xD;
                   MapThread[Rescale[Range[#1] // N // Rescale, {0, 1}, #2] &amp;amp;]&#xD;
                   , Tuples&#xD;
                   , AssociationThread[{&amp;#034;cX&amp;#034;, &amp;#034;cY&amp;#034;}, #\[Transpose]] &amp;amp;&#xD;
                   , AbsoluteTiming[mandelbrotConsF[#, WorkingPrecision -&amp;gt; &amp;#034;Real64&amp;#034;, TargetDevice -&amp;gt; &amp;#034;GPU&amp;#034;]] &amp;amp;&#xD;
                   , pipe[&#xD;
                            branch[pipe[First, Quantity[#, &amp;#034;Seconds&amp;#034;] &amp;amp;, Echo[#, &amp;#034;Computing time on NN:&amp;#034;] &amp;amp;], Last]&#xD;
                            , Last]&#xD;
                   , Developer`ToPackedArray&#xD;
                   , ArrayReshape[#, {2, Sequence @@ resol}] &amp;amp;&#xD;
                   , {1, I}.# &amp;amp;&#xD;
                   , Transpose, Reverse&#xD;
                 ]&#xD;
        ];&#xD;
&#xD;
(* Computing time on NN: 6.06289 s *)&#xD;
```&#xD;
```&#xD;
result // pipe[&#xD;
                branch[&#xD;
                        pipe[ Abs&#xD;
                            , pipe[branch[Flatten /* HistogramTransform, Dimensions /* Last], Apply@Partition]&#xD;
                            , Rescale, (1 - #)^5 &amp;amp;, Sin[\[Pi]/2 #] &amp;amp;, Rescale&#xD;
                            ]&#xD;
                      , pipe[Arg, Sin[#/2] &amp;amp;, Rescale]&#xD;
                      ]&#xD;
              , Map@pipe[ Image[#, ImageSize -&amp;gt; Round[Length[#]/2]] &amp;amp;&#xD;
                        , Colorize[#, ColorFunction -&amp;gt; &amp;#034;StarryNightColors&amp;#034;] &amp;amp;&#xD;
                        ]&#xD;
              ]&#xD;
```&#xD;
&#xD;
![zoom-inAt(-0.65+0.47I,-0.4+0.72I)][17]&#xD;
&#xD;
### Complex map&#xD;
&#xD;
We can also stylize the result any way we want, say, showing the complex mapping like the [`ComplexPlot`](https://reference.wolfram.com/language/ref/ComplexPlot.html).&#xD;
&#xD;
Abs vs. Arg:&#xD;
&#xD;
```&#xD;
result // pipe[&#xD;
                branch[&#xD;
                        pipe[ Arg&#xD;
                            , branch[&#xD;
                                      pipe[Sin[#/2] &amp;amp;, Rescale]&#xD;
                                    , pipe[&#xD;
                                            Sin[50 #] &amp;amp;, ArcSin, Rescale, #^.5 &amp;amp;&#xD;
                                          ]&#xD;
                                    ]&#xD;
                            ]&#xD;
                      , pipe[&#xD;
                              Abs&#xD;
                            , Rescale, Log[10^-3 + #] &amp;amp;, Rescale&#xD;
                            , branch[&#xD;
                                      pipe[Sin[200 #] &amp;amp;, ArcSin, Rescale, #^.5 &amp;amp;]&#xD;
                                    , pipe[#^5 &amp;amp;, Rescale[#, {0, 1}, {1, .3}] &amp;amp;]&#xD;
                                    ]&#xD;
                            ]&#xD;
                      ]&#xD;
              , Apply@Function[{arg2, abs2}, {arg2[[1]], arg2[[2]] abs2[[1]], abs2[[2]]}]&#xD;
              , Image[#, ColorSpace -&amp;gt; &amp;#034;HSB&amp;#034;, Interleaving -&amp;gt; False] &amp;amp;&#xD;
              ]&#xD;
```&#xD;
&#xD;
![Complex map: Abs vs Arg][18]&#xD;
&#xD;
Or Re vs. Im:&#xD;
&#xD;
```&#xD;
result // pipe[&#xD;
                branch[&#xD;
                      pipe[&#xD;
                            ReIm, Transpose[#, {2, 3, 1}] &amp;amp;&#xD;
                          , Map@pipe[&#xD;
                                      Cos[100 2 \[Pi] #] &amp;amp;, Rescale, #^.2 &amp;amp;&#xD;
                                    ]&#xD;
                          ]&#xD;
                      , pipe[&#xD;
                              Abs&#xD;
                            , Rescale, Log[10^-3 + #] &amp;amp;, Rescale&#xD;
                            , branch[&#xD;
                                      pipe[Sin[\[Pi]/2 #] &amp;amp;, Rescale]&#xD;
                                    , pipe[#^5 &amp;amp;, Rescale[#, {0, 1}, {1, .5}] &amp;amp;]&#xD;
                                    ]&#xD;
                            ]&#xD;
                      ]&#xD;
              , Apply@Function[{reim, abs2}, {abs2[[1]], Times @@ reim, abs2[[2]]}]&#xD;
              , Image[#, ColorSpace -&amp;gt; &amp;#034;HSB&amp;#034;, Interleaving -&amp;gt; False] &amp;amp;&#xD;
              ]&#xD;
```&#xD;
&#xD;
![Complex map: Re vs Im][19]&#xD;
&#xD;
### A different region&#xD;
&#xD;
(The detailed code in this section is omitted in the post, but included in the attached notebook.)&#xD;
&#xD;
Computing over a different region (`-0.0452407411 + 0.9868162204352258 I + 2.7 10^-5 {-1 - I, 1 + I}`) and fiddling with color palettes from `ColorData[&amp;#034;ThemeGradients&amp;#034;]` gives us this wallpaper-like result (the [`ColorFunction`](https://reference.wolfram.com/language/ref/Colorize.html#777264821) used here is `&amp;#034;M10DefaultDensityGradient&amp;#034;`).&#xD;
&#xD;
![zoom-in 2][20]&#xD;
&#xD;
Also the corresponding complex map plots:&#xD;
&#xD;
![complex maps: Abs vs Arg &amp;amp; Re vs Im][21]&#xD;
&#xD;
---&#xD;
&#xD;
# References&#xD;
&#xD;
 - [Exploding the Dark Heart of Chaos](https://dhushara.com/DarkHeart/DarkHeart.htm)&#xD;
 &#xD;
 - [Wikipedia: External ray](https://en.wikipedia.org/wiki/External_ray)&#xD;
 &#xD;
 - [MathWorld: Mandelbrot Set](http://mathworld.wolfram.com/MandelbrotSet.html)&#xD;
 &#xD;
 - [Wikipedia: Mandelbrot set](https://en.wikipedia.org/wiki/Mandelbrot_set)&#xD;
&#xD;
 - [The Mandelbrot Set Browser](http://www.cuug.ab.ca/dewara/mandelbrot/Mandelbrowser.html)&#xD;
&#xD;
  [1]: https://community.wolfram.com//c/portal/getImageAttachment?filename=Mandelbrot_wallpaper.png&amp;amp;userId=93201&#xD;
  [2]: https://community.wolfram.com//c/portal/getImageAttachment?filename=9_iteration_abs.png&amp;amp;userId=93201&#xD;
  [3]: https://community.wolfram.com//c/portal/getImageAttachment?filename=ReIm_Complex_map.png&amp;amp;userId=93201&#xD;
  [4]: https://community.wolfram.com//c/portal/getImageAttachment?filename=3D_mesh.png&amp;amp;userId=93201&#xD;
  [5]: https://community.wolfram.com//c/portal/getImageAttachment?filename=MandelbrotSetPlot.png&amp;amp;userId=93201&#xD;
  [6]: https://community.wolfram.com//c/portal/getImageAttachment?filename=time_bench_MandelbrotSetPlot.png&amp;amp;userId=93201&#xD;
  [7]: https://community.wolfram.com//c/portal/getImageAttachment?filename=iterNet.png&amp;amp;userId=93201&#xD;
  [8]: https://community.wolfram.com//c/portal/getImageAttachment?filename=iterNet_Nest.png&amp;amp;userId=93201&#xD;
  [9]: https://community.wolfram.com//c/portal/getImageAttachment?filename=NetNestPartialOperator_example.png&amp;amp;userId=93201&#xD;
  [10]: https://community.wolfram.com//c/portal/getImageAttachment?filename=nestcoreNet.png&amp;amp;userId=93201&#xD;
  [11]: https://community.wolfram.com//c/portal/getImageAttachment?filename=naive_result.png&amp;amp;userId=93201&#xD;
  [12]: https://community.wolfram.com//c/portal/getImageAttachment?filename=MandelbrotSetPlot2.png&amp;amp;userId=93201&#xD;
  [13]: https://community.wolfram.com//c/portal/getImageAttachment?filename=time_bench_NN.png&amp;amp;userId=93201&#xD;
  [14]: https://community.wolfram.com//c/portal/getImageAttachment?filename=time_bench_comparison.png&amp;amp;userId=93201&#xD;
  [15]: https://community.wolfram.com//c/portal/getImageAttachment?filename=constrained_result.png&amp;amp;userId=93201&#xD;
  [16]: https://community.wolfram.com//c/portal/getImageAttachment?filename=classical_Mandelbrot_200.png&amp;amp;userId=93201&#xD;
  [17]: https://community.wolfram.com//c/portal/getImageAttachment?filename=zoom_in_1.png&amp;amp;userId=93201&#xD;
  [18]: https://community.wolfram.com//c/portal/getImageAttachment?filename=AbsArg_Complex_map.png&amp;amp;userId=93201&#xD;
  [19]: https://community.wolfram.com//c/portal/getImageAttachment?filename=ReIm_Complex_map.png&amp;amp;userId=93201&#xD;
  [20]: https://community.wolfram.com//c/portal/getImageAttachment?filename=Mandelbrot_wallpaper.png&amp;amp;userId=93201&#xD;
  [21]: https://community.wolfram.com//c/portal/getImageAttachment?filename=complex_maps_2.png&amp;amp;userId=93201</description>
    <dc:creator>Silvia Hao</dc:creator>
    <dc:date>2019-12-19T07:59:59Z</dc:date>
  </item>
  <item rdf:about="https://community.wolfram.com/groups/-/m/t/3495066">
    <title>[WSS25] Visual and statistical analysis of LLMs via problem complexity</title>
    <link>https://community.wolfram.com/groups/-/m/t/3495066</link>
    <description>![Visual and statistical analysis of LLMs via problem complexity][1]&#xD;
&#xD;
&amp;amp;[Wolfram Notebook][2]&#xD;
&#xD;
&#xD;
  [1]: https://community.wolfram.com//c/portal/getImageAttachment?filename=HeroImage-WSS25.bmp&amp;amp;userId=3492577&#xD;
  [2]: https://www.wolframcloud.com/obj/2bc91532-706a-4dbe-ab99-4446339eba44</description>
    <dc:creator>Rakesh Vijay Kumar</dc:creator>
    <dc:date>2025-07-08T21:23:18Z</dc:date>
  </item>
  <item rdf:about="https://community.wolfram.com/groups/-/m/t/2931334">
    <title>100 Math Problems: ChatGPT with Wolfram Plugin versus the Code Interpreter Model</title>
    <link>https://community.wolfram.com/groups/-/m/t/2931334</link>
    <description>![enter image description here][1]&#xD;
&#xD;
&amp;amp;[Wolfram Notebook][2]&#xD;
&#xD;
&#xD;
  [1]: https://community.wolfram.com//c/portal/getImageAttachment?filename=rtapis-5.png&amp;amp;userId=20103&#xD;
  [2]: https://www.wolframcloud.com/obj/730d5d38-e03f-49fc-8b91-6de321867da6</description>
    <dc:creator>Michael Trott</dc:creator>
    <dc:date>2023-06-05T15:18:09Z</dc:date>
  </item>
  <item rdf:about="https://community.wolfram.com/groups/-/m/t/2137315">
    <title>Build a 3D Self-Driving Car Simulation</title>
    <link>https://community.wolfram.com/groups/-/m/t/2137315</link>
    <description>## Introduction&#xD;
&#xD;
In this article we will create a simple driving simulation to train a classifier to autonomously drive a virtual car. Our simulation will consist of a 3D scene composed of a windy road and a single car controller either by the user or the computer. The car will have a camera positioned in front of it to provide an image from its point of view (POV). This point of view image will be used as the input to our classifier to decide how to control the car. During each step of the simulation the car will be allowed to move forward or turn in place left or right.&#xD;
&#xD;
![enter image description here][1]&#xD;
&#xD;
## Building the Simulation&#xD;
&#xD;
### Simulation Graphics&#xD;
&#xD;
We will begin by creating the graphics functions to assemble and display the simulation. First lets create a texture for the ground. For simplicity we will rasterize a built-in curve containing both left and right turns for the road.&#xD;
&#xD;
    track = Rasterize[&#xD;
      With[{road = &#xD;
         HilbertCurve[2, DataRange -&amp;gt; {{0.25, 1.75}, {0.25, 1.75}}] /. &#xD;
          Line -&amp;gt; BSplineCurve},&#xD;
       Graphics[{&#xD;
         CapForm[&amp;#034;Round&amp;#034;],&#xD;
         Gray, AbsoluteThickness[36], road,&#xD;
         Yellow, Dashing[0.033], AbsoluteThickness[2], road&#xD;
         },&#xD;
        PlotRange -&amp;gt; {{0, 2}, {0, 2}},&#xD;
        Background -&amp;gt; RGBColor[&amp;#034;#e8e1ba&amp;#034;]&#xD;
        ]&#xD;
       ]&#xD;
      ]&#xD;
&#xD;
![enter image description here][2]&#xD;
&#xD;
Next we will define a function to assemble the 3D scene encompassing the ground and car. We will be rendering this scene with two different cameras to provide an overview of the car on the road as well as the car&amp;#039;s point of view image.&#xD;
&#xD;
    CarSimScene[sim_] := Module[{ground, car},&#xD;
      ground = {&#xD;
        Texture[track],&#xD;
        EdgeForm[None],&#xD;
        Polygon[&#xD;
         {{0, 0, 0}, {100, 0, 0}, {100, 100, 0}, {0, 100, 0}}, &#xD;
         VertexTextureCoordinates -&amp;gt; {{0, 0}, {1, 0}, {1, 1}, {0, 1}}&#xD;
         ]&#xD;
        };&#xD;
      &#xD;
      car =&#xD;
       With[{dimensions = {2, 1, 0}},&#xD;
        {Red,&#xD;
         Rotate[&#xD;
          Cuboid[sim[&amp;#034;Position&amp;#034;] - dimensions , &#xD;
           sim[&amp;#034;Position&amp;#034;] + dimensions + {0, 0, 1}], sim[&amp;#034;Rotation&amp;#034;],&#xD;
          {0, 0, 1},&#xD;
          sim[&amp;#034;Position&amp;#034;]&#xD;
          ]&#xD;
         }&#xD;
        ];&#xD;
      &#xD;
      {ground, car}&#xD;
      ]&#xD;
&#xD;
Lastly we need a function to position a camera in the 3D scene at the location of the car to record the point of view image. This image will only be used when classifying, so we rasterize at a relatively low resolution. After some experimentation I chose to use ImageResolution instead of RasterSize because it was over 2x faster to generate the final image. The ViewVector coordinates were determined experimentally to match the typical view from inside a car.&#xD;
&#xD;
    CarPOV[sim_] := Module[{&#xD;
       rotation = sim[&amp;#034;Rotation&amp;#034;],&#xD;
       pos = sim[&amp;#034;Position&amp;#034;]&#xD;
       },&#xD;
      Rasterize[&#xD;
       Graphics3D[&#xD;
        CarSimScene[sim],&#xD;
        ImageSize -&amp;gt; Small,&#xD;
        ViewVector -&amp;gt; {&#xD;
          sim[&amp;#034;Position&amp;#034;] + {2.1 Cos[sim[&amp;#034;Rotation&amp;#034;]], &#xD;
            2.1 Sin[sim[&amp;#034;Rotation&amp;#034;]], 1.5},&#xD;
          sim[&amp;#034;Position&amp;#034;] + {5 Cos[sim[&amp;#034;Rotation&amp;#034;]], &#xD;
            5 Sin[sim[&amp;#034;Rotation&amp;#034;]], -0.25}&#xD;
          },&#xD;
        ViewAngle -&amp;gt; 1.5,&#xD;
        Boxed -&amp;gt; False,&#xD;
        Background -&amp;gt; LightBlue,&#xD;
        ViewRange -&amp;gt; {0, 0.1}&#xD;
        ],&#xD;
       ImageResolution -&amp;gt; 8&#xD;
       ]&#xD;
      ]&#xD;
&#xD;
We can now put all of our graphics functions together into a single overarching function that displays the entire car simulation including the 3D scene and an inset from the car&amp;#039;s point of view.&#xD;
&#xD;
    DisplayCarSim[sim_] := Module[{},&#xD;
      Overlay[{&#xD;
        Graphics3D[&#xD;
         CarSimScene[sim],&#xD;
         PlotRange -&amp;gt; {{0, 100}, {0, 100}, Automatic},&#xD;
         ImageSize -&amp;gt; Large,&#xD;
         Background -&amp;gt; LightBlue,&#xD;
         Boxed -&amp;gt; False&#xD;
         ],&#xD;
        Labeled[&#xD;
         Framed[sim[&amp;#034;POV&amp;#034;], FrameMargins -&amp;gt; None, FrameStyle -&amp;gt; Gray, &#xD;
          ImageSize -&amp;gt; Small], &amp;#034;Car POV&amp;#034;, LabelStyle -&amp;gt; Gray]&#xD;
        }]&#xD;
      ]&#xD;
&#xD;
### Simulation Internals&#xD;
&#xD;
With our simulation graphics complete we will proceed to building the functions that step the simulation forward. Our simulation state will be contained in a single association containing properties for the car&amp;#039;s position, rotation, and current POV image, along with the history of all previous POV images and their associated actions.&#xD;
&#xD;
NewCarSim initializes our data model for a new simulation. We allow a parameter to define which direction on the track the car starts from. We will generate training data in the &amp;#034;Forward&amp;#034; direction and then test the trained self-driving car in the opposite direction.&#xD;
&#xD;
    NewCarSim[direction_] := Module[{sim},&#xD;
      sim = If[&#xD;
        SymbolName[direction] == &amp;#034;Forward&amp;#034;,&#xD;
        &amp;lt;|&amp;#034;Position&amp;#034; -&amp;gt; {10, 10, 0}, &amp;#034;Rotation&amp;#034; -&amp;gt; 0|&amp;gt;,&#xD;
        &amp;lt;|&amp;#034;Position&amp;#034; -&amp;gt; {90, 14, 0}, &amp;#034;Rotation&amp;#034; -&amp;gt; Pi|&amp;gt;&#xD;
        ];&#xD;
      sim[&amp;#034;History&amp;#034;] = {};&#xD;
      sim[&amp;#034;POV&amp;#034;] = CarPOV[sim];&#xD;
      sim&#xD;
      ]&#xD;
&#xD;
Advancing the simulation is easy, StepCarSim takes a simulation state and action, one of &amp;#034;Up&amp;#034;, &amp;#034;Left&amp;#034;, or &amp;#034;Right&amp;#034;, and moves the car accordingly. Every time the simulation is stepped forward the current car POV image is saved along with the provided action in our history list. At the end of a simulation step a new car POV image is generated.&#xD;
&#xD;
    StepCarSim[sim_, action_] := Module[{},&#xD;
       AppendTo[sim[&amp;#034;History&amp;#034;], sim[&amp;#034;POV&amp;#034;] -&amp;gt; action];&#xD;
       &#xD;
       Switch[&#xD;
        action,&#xD;
        &amp;#034;Left&amp;#034;, sim[&amp;#034;Rotation&amp;#034;] += 0.05,&#xD;
        &amp;#034;Right&amp;#034;, sim[&amp;#034;Rotation&amp;#034;] -= 0.05,&#xD;
        &amp;#034;Up&amp;#034;, &#xD;
        sim[&amp;#034;Position&amp;#034;] += {Cos[sim[&amp;#034;Rotation&amp;#034;]], Sin[sim[&amp;#034;Rotation&amp;#034;]], &#xD;
          0}&#xD;
        ];&#xD;
       &#xD;
       sim[&amp;#034;POV&amp;#034;] = CarPOV[sim];&#xD;
       &#xD;
       sim&#xD;
       ];&#xD;
    SetAttributes[StepCarSim, HoldFirst];&#xD;
&#xD;
Our simulation is nearly complete, now it is time to build the interactive interface which allows a person to drive the car and generate training data.&#xD;
&#xD;
## Generating Example Training Data&#xD;
&#xD;
    sim = NewCarSim[Forward];&#xD;
    EventHandler[&#xD;
     Style[Dynamic[DisplayCarSim[sim]], Selectable -&amp;gt; False],&#xD;
     {&#xD;
      &amp;#034;LeftArrowKeyDown&amp;#034; :&amp;gt; StepCarSim[sim, &amp;#034;Left&amp;#034;],&#xD;
      &amp;#034;RightArrowKeyDown&amp;#034; :&amp;gt; StepCarSim[sim, &amp;#034;Right&amp;#034;],&#xD;
      &amp;#034;UpArrowKeyDown&amp;#034; :&amp;gt; StepCarSim[sim, &amp;#034;Up&amp;#034;]&#xD;
      }&#xD;
     ]&#xD;
&#xD;
![enter image description here][3]&#xD;
&#xD;
When I manually drove the car down the length of the entire track, the simulation generated nearly 600 training examples. This data is available in the Supplemental Materials section below if you would prefer not to create your own. Lets take a look at a few of the training examples:&#xD;
&#xD;
    TableForm@RandomSample[sim[&amp;#034;History&amp;#034;], 3]&#xD;
&#xD;
![enter image description here][4]&#xD;
&#xD;
## Training the Self-Driving Car&#xD;
&#xD;
Having generated our example data, we are now ready to train a classifier to drive the car!&#xD;
&#xD;
    selfDrivingCar = &#xD;
     Classify[sim[&amp;#034;History&amp;#034;], Method -&amp;gt; &amp;#034;LogisticRegression&amp;#034;]&#xD;
&#xD;
![enter image description here][5]&#xD;
&#xD;
I chose to specify logistic regression because it provided the best accuracy for a relatively small evaluation time. We can show information about our classifier and see accuracy above 70%. By inspecting the learning curve and accuracy curve it looks like we are approaching a limit to our learning, but could probably still benefit from a few more training examples. Still, with our modest amount of example data, the autonomous car performs well.&#xD;
&#xD;
    Information[selfDrivingCar]&#xD;
&#xD;
![enter image description here][6]&#xD;
&#xD;
To preview our self-driving car we will step the simulation one hundred times using our new classifier to drive the car. This only gets us a little ways around the track, but shows the classifier is working.&#xD;
&#xD;
    DynamicModule[{selfDrivingSim = NewCarSim[Backward]},&#xD;
     Print[Dynamic[DisplayCarSim[selfDrivingSim]]];&#xD;
     Do[StepCarSim[selfDrivingSim, selfDrivingCar[selfDrivingSim[&amp;#034;POV&amp;#034;]]],&#xD;
       100];&#xD;
     ]&#xD;
&#xD;
![enter image description here][7]&#xD;
&#xD;
We could increase the number of steps to see the car drive to the end, but due to the relatively slow rendering performance I prefer to pre-render every 5th or 10th frame and assemble those in a Manipulate to easily pan back and forth through time:&#xD;
&#xD;
    selfDrivingSim = NewCarSim[Backward];&#xD;
    frames = Table[&#xD;
       With[{img = Rasterize[DisplayCarSim[selfDrivingSim]]},&#xD;
        Do[StepCarSim[selfDrivingSim, &#xD;
          selfDrivingCar[selfDrivingSim[&amp;#034;POV&amp;#034;]]], 5];&#xD;
        img&#xD;
        ],&#xD;
       120&#xD;
       ];&#xD;
    &#xD;
    Manipulate[frames[[t]], {t, 1, Length[frames] - 1, 1}]&#xD;
&#xD;
![enter image description here][8]&#xD;
&#xD;
So, how well does our self-driving car work? Quite well as a matter of fact. It can easily make it down the entire track, and stays on the right side of the road too! But what happens if we start the car on the wrong side of the road? Does it get confused? Let&amp;#039;s see:&#xD;
&#xD;
    DynamicModule[{selfDrivingSim = NewCarSim[Backward]},&#xD;
     selfDrivingSim[&amp;#034;Position&amp;#034;] -= {0, 4, 0};&#xD;
     Print[Dynamic[DisplayCarSim[selfDrivingSim]]];&#xD;
     Do[StepCarSim[selfDrivingSim, selfDrivingCar[selfDrivingSim[&amp;#034;POV&amp;#034;]]],&#xD;
       100];&#xD;
     ]&#xD;
&#xD;
![enter image description here][9]&#xD;
&#xD;
When starting on the wrong side of the road the self-driving car immediately corrects and steers back to the right side! Our car works wonderfully, especially considering the modest training set and limited manual optimization of Classify.&#xD;
&#xD;
## Conclusion&#xD;
&#xD;
In conclusion we can use Mathematica to create and render a 3D simulation while also interfacing with its machine learning tools to build a complete end to end experimental system. I hope this example provides some insight into the power of Mathematica&amp;#039;s machine learning and graphics capabilities.&#xD;
&#xD;
&#xD;
  [1]: https://community.wolfram.com//c/portal/getImageAttachment?filename=ezgif-6-c4f303fe5f33.gif&amp;amp;userId=11733&#xD;
  [2]: https://community.wolfram.com//c/portal/getImageAttachment?filename=ScreenShot2020-12-13at2.19.25PM.png&amp;amp;userId=2137254&#xD;
  [3]: https://community.wolfram.com//c/portal/getImageAttachment?filename=ScreenShot2020-12-13at2.22.36PM.png&amp;amp;userId=2137254&#xD;
  [4]: https://community.wolfram.com//c/portal/getImageAttachment?filename=10103ScreenShot2020-12-13at2.23.23PM.png&amp;amp;userId=2137254&#xD;
  [5]: https://community.wolfram.com//c/portal/getImageAttachment?filename=9171ScreenShot2020-12-13at2.24.29PM.png&amp;amp;userId=2137254&#xD;
  [6]: https://community.wolfram.com//c/portal/getImageAttachment?filename=5376ScreenShot2020-12-13at2.25.22PM.png&amp;amp;userId=2137254&#xD;
  [7]: https://community.wolfram.com//c/portal/getImageAttachment?filename=ScreenShot2020-12-13at2.26.30PM.png&amp;amp;userId=2137254&#xD;
  [8]: https://community.wolfram.com//c/portal/getImageAttachment?filename=ScreenShot2020-12-13at2.27.13PM.png&amp;amp;userId=2137254&#xD;
  [9]: https://community.wolfram.com//c/portal/getImageAttachment?filename=2628correcting-self-driving-car.gif&amp;amp;userId=2137254</description>
    <dc:creator>Dan Bridges</dc:creator>
    <dc:date>2020-12-13T22:43:34Z</dc:date>
  </item>
  <item rdf:about="https://community.wolfram.com/groups/-/m/t/2469295">
    <title>[BOOK] Introduction to machine learning</title>
    <link>https://community.wolfram.com/groups/-/m/t/2469295</link>
    <description>*WOLFRAM MATERIALS for the BOOK:*&#xD;
&amp;gt; Etienne Bernard, *Introduction to Machine Learning*.&#xD;
&#xD;
&amp;gt; Wolfram Media: https://www.wolfram-media.com/products/introduction-to-machine-learning.html&#xD;
&#xD;
&amp;gt; Amazon: http://amzn.to/3oky6AC&#xD;
&#xD;
&amp;gt; ISBN: 978-1579550486&#xD;
&#xD;
&amp;gt; Code-only notebooks: https://wolfr.am/iml&#xD;
&#xD;
[![enter image description here][1]][2]&#xD;
&#xD;
## Introduction&#xD;
&#xD;
Hi everyone! For those who don&amp;#039;t known me, I worked at Wolfram Research for 8 years (went pretty fast!) and led the development of the machine learning tools that are now part of the Wolfram Language (Classify, Predict, NetTrain, ...). It is now time for me to go on other adventures, but I couldn&amp;#039;t leave &amp;#034;just like this&amp;#034;, and decided to write a book called &amp;#034;Introduction to Machine Learning” http://amzn.to/3oky6AC to share my understanding of this field after these years of tool design and development. Writing this book has been quite of a journey, with some ups and downs, but it was overall pretty fun to play with the tools we built and figuring out the best ways to introduce machine learning. This book is intended for a general audience and has three goals:&#xD;
&#xD;
 1. Explain what machine learning is.&#xD;
 2. Teach how to practice machine learning.&#xD;
 3. Give an understanding of how machine learning works.&#xD;
&#xD;
It is written in a computational essay style (alternating text and simple computations - basically a long WL notebook), with lots of illustrations and examples. The code snippets are used to show how to practice machine learning, to illustrate concepts, and to complement - or even replace - mathematical formulations. It was quite nice to see how much math could be removed thanks to code (although, I often made the decision to explain concepts both with formulas and code snippets, to have the best of both worlds).&#xD;
Anyway, I encourage you to have a look at it, I included chapter 3 as a notebook in this post, I hope that you enjoy it or at least find it useful  You can also check out the code-only notebooks https://wolfr.am/iml which contain both code snippets and illustrations code.&#xD;
&#xD;
**PS:** I am starting a weekly *#MLConcept* post series on Twitter [@etiennebcp][3] to highlight the most important topics and start conversations. You are welcome to join in!&#xD;
&#xD;
## Sample chapter&#xD;
&#xD;
&amp;amp;[Wolfram Notebook][4]&#xD;
&#xD;
&#xD;
  [1]: https://community.wolfram.com//c/portal/getImageAttachment?filename=8296book_cover.jpg&amp;amp;userId=20103&#xD;
  [2]: https://community.wolfram.com//c/portal/getImageAttachment?filename=8296book_cover.jpg&amp;amp;userId=20103&#xD;
  [3]: https://twitter.com/etiennebcp&#xD;
  [4]: https://www.wolframcloud.com/obj/f0adf08b-7ebf-48a3-942e-e2473b561a97</description>
    <dc:creator>Etienne Bernard</dc:creator>
    <dc:date>2022-02-11T19:33:27Z</dc:date>
  </item>
  <item rdf:about="https://community.wolfram.com/groups/-/m/t/1093926">
    <title>Transfer an artistic style to an image</title>
    <link>https://community.wolfram.com/groups/-/m/t/1093926</link>
    <description>![enter image description here][16]&#xD;
&#xD;
# Introduction &#xD;
&#xD;
Back in [Wolfram Summer School 2016][1] I worked on the project &amp;#034;Image Transformation with Neural Networks: Real-Time Style Transfer and Super-Resolution&amp;#034;, which got later [published on Wolfram Community][2]. At the time I had to use the MXNetLink package, but now all the needed functionality is built-in, so here is a top-level implementation of artistic style transfer with Wolfram Language. This is a slightly simplified version of the original method, as it uses a single VGG layer to extract the style features, but a full implementation is of course possible with minor modifications to the code. You can also find this example in the docs: &#xD;
&#xD;
[NetTrain][3] &amp;gt;&amp;gt; Applications &amp;gt;&amp;gt; Computer Vision &amp;gt;&amp;gt; Style Transfer &#xD;
&#xD;
# Code&#xD;
&#xD;
Create a new image with the content of a given image and in the style of another given image. This implementation follows the method described in Gatys et al., *A Neural Algorithm of Artistic Style*. An example content and style image:&#xD;
&#xD;
![enter image description here][4]&#xD;
&#xD;
To create the image which is a mix of both of these images, start by obtaining a pre-trained image classification network:&#xD;
&#xD;
    vggNet = NetModel[&amp;#034;VGG-16 Trained on ImageNet Competition Data&amp;#034;];&#xD;
Take a subnet that will be used as a feature extractor for the style and content images:&#xD;
&#xD;
    featureNet = Take[vggNet, {1, &amp;#034;relu4_1&amp;#034;}]&#xD;
![enter image description here][5]&#xD;
&#xD;
There are three loss functions used. The first loss ensures that the &amp;#034;content&amp;#034; is similar in the synthesized image and the content image:&#xD;
&#xD;
    contentLoss = NetGraph[{MeanSquaredLossLayer[]}, {1 -&amp;gt; NetPort[&amp;#034;LossContent&amp;#034;]}]&#xD;
![enter image description here][6]&#xD;
&#xD;
The second loss ensures that the &amp;#034;style&amp;#034; is similar in the synthesized image and the style image. Style similarity is defined as the mean-squared difference between the Gram matrices of the input and target:&#xD;
&#xD;
    gramMatrix = NetGraph[{FlattenLayer[-1], TransposeLayer[1 -&amp;gt; 2],   DotLayer[]}, {1 -&amp;gt; 3, 1 -&amp;gt; 2 -&amp;gt; 3}];&#xD;
&#xD;
    styleLoss = NetGraph[{gramMatrix, gramMatrix, MeanSquaredLossLayer[]},&#xD;
    {NetPort[&amp;#034;Input&amp;#034;] -&amp;gt; 1, NetPort[&amp;#034;Target&amp;#034;] -&amp;gt; 2, {1, 2} -&amp;gt; 3,  3 -&amp;gt; NetPort[&amp;#034;LossStyle&amp;#034;]}]&#xD;
![enter image description here][7]&#xD;
&#xD;
The third loss ensures that the magnitude of intensity changes across adjacent pixels in the synthesized image is small. This helps the synthesized image look more natural:&#xD;
&#xD;
    l2Loss = NetGraph[{ThreadingLayer[(#1 - #2)^2 &amp;amp;], SummationLayer[]}, {{NetPort[&amp;#034;Input&amp;#034;], NetPort[&amp;#034;Target&amp;#034;]} -&amp;gt; 1 -&amp;gt; 2}];&#xD;
&#xD;
    tvLoss = NetGraph[&amp;lt;|&#xD;
       &amp;#034;dx1&amp;#034; -&amp;gt; PaddingLayer[{{0, 0}, {1, 0}, {0, 0}}, &amp;#034;Padding&amp;#034; -&amp;gt; &amp;#034;Fixed&amp;#034; ],&#xD;
       &amp;#034;dx2&amp;#034; -&amp;gt;  PaddingLayer[{{0, 0}, {0, 1}, {0, 0}}, &amp;#034;Padding&amp;#034; -&amp;gt; &amp;#034;Fixed&amp;#034;],&#xD;
       &amp;#034;dy1&amp;#034; -&amp;gt;  PaddingLayer[{{0, 0}, {0, 0}, {1, 0}}, &amp;#034;Padding&amp;#034; -&amp;gt; &amp;#034;Fixed&amp;#034; ],&#xD;
       &amp;#034;dy2&amp;#034; -&amp;gt;  PaddingLayer[{{0, 0}, {0, 0}, {0, 1}}, &amp;#034;Padding&amp;#034; -&amp;gt; &amp;#034;Fixed&amp;#034;],&#xD;
       &amp;#034;lossx&amp;#034; -&amp;gt; l2Loss, &amp;#034;lossy&amp;#034; -&amp;gt; l2Loss, &amp;#034;tot&amp;#034; -&amp;gt; TotalLayer[]|&amp;gt;,&#xD;
     {{&amp;#034;dx1&amp;#034;, &amp;#034;dx2&amp;#034;} -&amp;gt; &amp;#034;lossx&amp;#034;, {&amp;#034;dy1&amp;#034;, &amp;#034;dy2&amp;#034;} -&amp;gt; &amp;#034;lossy&amp;#034;,&#xD;
       {&amp;#034;lossx&amp;#034;, &amp;#034;lossy&amp;#034;} -&amp;gt; &amp;#034;tot&amp;#034; -&amp;gt; NetPort[&amp;#034;LossTV&amp;#034;]}]&#xD;
![enter image description here][8]&#xD;
&#xD;
Define a function that creates the final training net for any content and style image. This function also creates a random initial image:&#xD;
&#xD;
    createTransferNet[net_, content_Image, styleFeatSize_] := Module[{dims = Prepend[3]@Reverse@ImageDimensions[content]},&#xD;
    NetGraph[&amp;lt;|&#xD;
    &amp;#034;Image&amp;#034; -&amp;gt; ConstantArrayLayer[&amp;#034;Array&amp;#034; -&amp;gt; RandomReal[{-0.1, 0.1}, dims]],&#xD;
    &amp;#034;imageFeat&amp;#034; -&amp;gt; NetReplacePart[net, &amp;#034;Input&amp;#034; -&amp;gt; dims],&#xD;
    &amp;#034;content&amp;#034; -&amp;gt; contentLoss,&#xD;
    &amp;#034;style&amp;#034; -&amp;gt; styleLoss,&#xD;
    &amp;#034;tv&amp;#034; -&amp;gt; tvLoss|&amp;gt;,&#xD;
    {&amp;#034;Image&amp;#034; -&amp;gt; &amp;#034;imageFeat&amp;#034;,&#xD;
    {&amp;#034;imageFeat&amp;#034;, NetPort[&amp;#034;ContentFeature&amp;#034;]} -&amp;gt; &amp;#034;content&amp;#034;,&#xD;
    {&amp;#034;imageFeat&amp;#034;, NetPort[&amp;#034;StyleFeature&amp;#034;]} -&amp;gt; &amp;#034;style&amp;#034;,&#xD;
    &amp;#034;Image&amp;#034; -&amp;gt; &amp;#034;tv&amp;#034;},&#xD;
    &amp;#034;StyleFeature&amp;#034; -&amp;gt; styleFeatSize   ] ]&#xD;
Define a [NetDecoder][9] for visualizing the predicted image:&#xD;
&#xD;
    meanIm = NetExtract[featureNet, &amp;#034;Input&amp;#034;][[&amp;#034;MeanImage&amp;#034;]]&#xD;
&#xD;
&amp;gt; {0.48502, 0.457957, 0.407604}&#xD;
&#xD;
    decoder = NetDecoder[{&amp;#034;Image&amp;#034;, &amp;#034;MeanImage&amp;#034; -&amp;gt; meanIm}]&#xD;
![enter image description here][10]&#xD;
&#xD;
The training data consists of features extracted from the content and style images. Define a feature extraction function:&#xD;
&#xD;
    extractFeatures[img_] := NetReplacePart[featureNet, &amp;#034;Input&amp;#034; -&amp;gt;NetEncoder[{&amp;#034;Image&amp;#034;, ImageDimensions[img], &#xD;
     &amp;#034;MeanImage&amp;#034; -&amp;gt;meanIm}]][img];&#xD;
&#xD;
Create a training set consisting of a single example of a content and style feature:&#xD;
&#xD;
    trainingdata = &amp;lt;|&#xD;
      &amp;#034;ContentFeature&amp;#034; -&amp;gt; {extractFeatures[contentImg]},&#xD;
       &amp;#034;StyleFeature&amp;#034; -&amp;gt; {extractFeatures[styleImg]}&#xD;
      |&amp;gt;&#xD;
Create the training net whose input dimensions correspond to the content and style image dimensions:&#xD;
&#xD;
    net = createTransferNet[featureNet, contentImg, &#xD;
       Dimensions@First@trainingdata[&amp;#034;StyleFeature&amp;#034;]];&#xD;
When training, the three losses are weighted differently to set the relative importance of the content and style. These values might need to be changed with different content and style images. Create a loss specification that defines the final loss as a combination of the three losses:&#xD;
&#xD;
    perPixel = 1/(3*Apply[Times, ImageDimensions[contentImg]]);&#xD;
    lossSpec = {&amp;#034;LossContent&amp;#034; -&amp;gt; Scaled[6.*10^-5], &#xD;
       &amp;#034;LossStyle&amp;#034; -&amp;gt; Scaled[0.5*10^-14], &#xD;
       &amp;#034;LossTV&amp;#034; -&amp;gt; Scaled[20.*perPixel]};&#xD;
Optimize the image using [NetTrain][11]. [LearningRateMultipliers][12] are used to freeze all parameters in the net except for the [ConstantArrayLayer][13]. The training is best done on a GPU, as it will take up to an hour to get good results with CPU training. The training can be stopped at any time via Evaluation -&amp;gt; Abort Evaluation:&#xD;
&#xD;
    trainedNet = NetTrain[net,&#xD;
      trainingdata, lossSpec,&#xD;
      LearningRateMultipliers -&amp;gt; {&amp;#034;Image&amp;#034; -&amp;gt; 1, _ -&amp;gt; None},&#xD;
      TrainingProgressReporting -&amp;gt; &#xD;
       Function[decoder[#Weights[{&amp;#034;Image&amp;#034;, &amp;#034;Array&amp;#034;}]]],&#xD;
      MaxTrainingRounds -&amp;gt; 300, BatchSize -&amp;gt; 1,&#xD;
      Method -&amp;gt; {&amp;#034;ADAM&amp;#034;, &amp;#034;InitialLearningRate&amp;#034; -&amp;gt; 0.05},&#xD;
      TargetDevice -&amp;gt; &amp;#034;GPU&amp;#034;&#xD;
      ]&#xD;
![enter image description here][14]&#xD;
&#xD;
Extract the final image from the [ConstantArrayLayer][15] of the trained net:&#xD;
&#xD;
    decoder[NetExtract[trainedNet, {&amp;#034;Image&amp;#034;, &amp;#034;Array&amp;#034;}]]&#xD;
&#xD;
![enter image description here][16]&#xD;
&#xD;
&#xD;
  [1]: https://education.wolfram.com/summer/school/alumni/2016/salvarezza/&#xD;
  [2]: http://community.wolfram.com/groups/-/m/t/885941&#xD;
  [3]: http://reference.wolfram.com/language/ref/NetTrain.html&#xD;
  [4]: http://community.wolfram.com//c/portal/getImageAttachment?filename=I_432.png&amp;amp;userId=95400&#xD;
  [5]: http://community.wolfram.com//c/portal/getImageAttachment?filename=O_179.png&amp;amp;userId=95400&#xD;
  [6]: http://community.wolfram.com//c/portal/getImageAttachment?filename=O_180.png&amp;amp;userId=95400&#xD;
  [7]: http://community.wolfram.com//c/portal/getImageAttachment?filename=O_181.png&amp;amp;userId=95400&#xD;
  [8]: http://community.wolfram.com//c/portal/getImageAttachment?filename=O_182.png&amp;amp;userId=95400&#xD;
  [9]: http://reference.wolfram.com/language/ref/NetDecoder.html&#xD;
  [10]: http://community.wolfram.com//c/portal/getImageAttachment?filename=O_184.png&amp;amp;userId=95400&#xD;
  [11]: http://reference.wolfram.com/language/ref/NetTrain.html&#xD;
  [12]: http://reference.wolfram.com/language/ref/LearningRateMultipliers.html&#xD;
  [13]: http://reference.wolfram.com/language/ref/ConstantArrayLayer.html&#xD;
  [14]: http://community.wolfram.com//c/portal/getImageAttachment?filename=O_185.png&amp;amp;userId=95400&#xD;
  [15]: http://reference.wolfram.com/language/ref/ConstantArrayLayer.html&#xD;
  [16]: http://community.wolfram.com//c/portal/getImageAttachment?filename=I_466.png&amp;amp;userId=95400</description>
    <dc:creator>Matteo Salvarezza</dc:creator>
    <dc:date>2017-05-15T10:33:59Z</dc:date>
  </item>
</rdf:RDF>

