{ "cells": [ { "cell_type": "code", "execution_count": 1, "metadata": { "collapsed": false }, "outputs": [], "source": [ "import mxnet as mx" ] }, { "cell_type": "code", "execution_count": 2, "metadata": { "collapsed": false }, "outputs": [], "source": [ "data = mx.sym.Variable('data')\n", "net = data\n", "pavg = mx.sym.Pooling(net, pool_type='avg', kernel=(8,8))\n", "pmax = mx.sym.Pooling(net, pool_type='max', kernel=(8,8))\n", "pavg = mx.sym.Flatten(pavg)\n", "pmax = mx.sym.Flatten(pmax)\n", "pmax = mx.sym.Activation(pmax, act_type='relu')\n", "net = pavg + pmax\n", "out = mx.sym.SoftmaxOutput(net)" ] }, { "cell_type": "code", "execution_count": 3, "metadata": { "collapsed": false, "scrolled": false }, "outputs": [ { "data": { "image/svg+xml": [ "\n", "\n", "\n", "\n", "\n", "\n", "plot\n", "\n", "\n", "data\n", "\n", "data\n", "\n", "\n", "pooling0\n", "\n", "Pooling\n", "avg, 8x8/1\n", "\n", "\n", "pooling0->data\n", "\n", "\n", "\n", "\n", "flatten0\n", "\n", "Flatten\n", "\n", "\n", "flatten0->pooling0\n", "\n", "\n", "\n", "\n", "pooling1\n", "\n", "Pooling\n", "max, 8x8/1\n", "\n", "\n", "pooling1->data\n", "\n", "\n", "\n", "\n", "flatten1\n", "\n", "Flatten\n", "\n", "\n", "flatten1->pooling1\n", "\n", "\n", "\n", "\n", "activation0\n", "\n", "Activation\n", "relu\n", "\n", "\n", "activation0->flatten1\n", "\n", "\n", "\n", "\n", "_plus0\n", "\n", "_Plus\n", "\n", "\n", "_plus0->flatten0\n", "\n", "\n", "\n", "\n", "_plus0->activation0\n", "\n", "\n", "\n", "\n", "softmaxoutput0\n", "\n", "SoftmaxOutput\n", "\n", "\n", "softmaxoutput0->_plus0\n", "\n", "\n", "\n", "\n", "\n" ], "text/plain": [ "" ] }, "execution_count": 3, "metadata": {}, "output_type": "execute_result" } ], "source": [ "mx.viz.plot_network(\n", " out,\n", " node_attrs={'fixedsize': 'fasle'}\n", ")" ] }, { "cell_type": "code", "execution_count": 4, "metadata": { "collapsed": true }, "outputs": [], "source": [ "data = mx.sym.Variable('data')\n", "net = data\n", "fco = []\n", "smo = []\n", "cum = None\n", "for ii in range(3):\n", " if ii > 0:\n", " if cum is None:\n", " cum = pos\n", " else:\n", " cum = cum + pos\n", " net = mx.sym.Concat(*[net, cum])\n", " neg = mx.sym.FullyConnected(net, num_hidden=1)\n", " pos = mx.sym.FullyConnected(net, num_hidden=1)\n", " fco.append(mx.sym.Concat(*[neg, pos]))\n", " smo.append(mx.sym.SoftmaxOutput(fco[ii]))\n", "out = mx.sym.Group(smo)" ] }, { "cell_type": "code", "execution_count": 5, "metadata": { "collapsed": false }, "outputs": [ { "data": { "image/svg+xml": [ "\n", "\n", "\n", "\n", "\n", "\n", "plot\n", "\n", "\n", "data\n", "\n", "data\n", "\n", "\n", "fullyconnected0\n", "\n", "FullyConnected\n", "1\n", "\n", "\n", "fullyconnected0->data\n", "\n", "\n", "\n", "\n", "fullyconnected1\n", "\n", "FullyConnected\n", "1\n", "\n", "\n", "fullyconnected1->data\n", "\n", "\n", "\n", "\n", "concat0\n", "\n", "Concat\n", "\n", "\n", "concat0->fullyconnected0\n", "\n", "\n", "\n", "\n", "concat0->fullyconnected1\n", "\n", "\n", "\n", "\n", "softmaxoutput1\n", "\n", "SoftmaxOutput\n", "\n", "\n", "softmaxoutput1->concat0\n", "\n", "\n", "\n", "\n", "concat1\n", "\n", "Concat\n", "\n", "\n", "concat1->data\n", "\n", "\n", "\n", "\n", "concat1->fullyconnected1\n", "\n", "\n", "\n", "\n", "fullyconnected2\n", "\n", "FullyConnected\n", "1\n", "\n", "\n", "fullyconnected2->concat1\n", "\n", "\n", "\n", "\n", "fullyconnected3\n", "\n", "FullyConnected\n", "1\n", "\n", "\n", "fullyconnected3->concat1\n", "\n", "\n", "\n", "\n", "concat2\n", "\n", "Concat\n", "\n", "\n", "concat2->fullyconnected2\n", "\n", "\n", "\n", "\n", "concat2->fullyconnected3\n", "\n", "\n", "\n", "\n", "softmaxoutput2\n", "\n", "SoftmaxOutput\n", "\n", "\n", "softmaxoutput2->concat2\n", "\n", "\n", "\n", "\n", "_plus1\n", "\n", "_Plus\n", "\n", "\n", "_plus1->fullyconnected1\n", "\n", "\n", "\n", "\n", "_plus1->fullyconnected3\n", "\n", "\n", "\n", "\n", "concat3\n", "\n", "Concat\n", "\n", "\n", "concat3->concat1\n", "\n", "\n", "\n", "\n", "concat3->_plus1\n", "\n", "\n", "\n", "\n", "fullyconnected4\n", "\n", "FullyConnected\n", "1\n", "\n", "\n", "fullyconnected4->concat3\n", "\n", "\n", "\n", "\n", "fullyconnected5\n", "\n", "FullyConnected\n", "1\n", "\n", "\n", "fullyconnected5->concat3\n", "\n", "\n", "\n", "\n", "concat4\n", "\n", "Concat\n", "\n", "\n", "concat4->fullyconnected4\n", "\n", "\n", "\n", "\n", "concat4->fullyconnected5\n", "\n", "\n", "\n", "\n", "softmaxoutput3\n", "\n", "SoftmaxOutput\n", "\n", "\n", "softmaxoutput3->concat4\n", "\n", "\n", "\n", "\n", "\n" ], "text/plain": [ "" ] }, "execution_count": 5, "metadata": {}, "output_type": "execute_result" } ], "source": [ "mx.viz.plot_network(\n", " out,\n", " node_attrs={'fixedsize': 'fasle'}\n", ")" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.5.2" } }, "nbformat": 4, "nbformat_minor": 1 }