经典神经网络架构参考 v1.0(2)https://developer.aliyun.com/article/1489284
下卷积块:
!
digraph ResNet18DownConvBlock { rankdir=BT node [ style=filled, color=Black fontcolor=White, fillcolor="#30638e", fontname="SimHei", fontsize=32, width=5, height=2, shape="box", ] inp [label="输入\n[BatchSize,\nW=BlockW, \nH=BlockH, C=BlockIn]", shape="Mrecord"] conv1 [label="Conv2D#1\n[K=3, S=2, P=1,\n In=BlockIn,\n Out=BlockOut]"] relu1 [label="Relu"] conv2 [label="Conv2D#2\n[K=3, P=1,\n In=BlockOut,\n Out=BlockOut]"] downconv [label="Conv2D#0\n[K=1, S=2,\n In=BlockIn,\n Out=BlockOut]"] add [label="+"] relu2 [label="Relu"] inp -> conv1 -> relu1 -> conv2 -> add -> relu2 -> oup inp -> downconv -> add }
3.5 DenseNet
主体:
digraph DenseNet { rankdir=BT node [ style=filled, color=Black fontcolor=White, fillcolor="#30638e", fontname="SimHei", fontsize=32, width=7, height=2, shape="box", ] inp [label="输入\n[BatchSize, W=224,\n H=224, C=3]"] conv0 [label="Conv2D#0\n[K=7, S=2, P=3,\nIn=3, Out=64]"] bn0 [label="BatchNorm2D(64)"] relu0 [label="Relu"] maxpool0 [label="MaxPool2D#0\n[K=3, S=2, P=1]"] featmap0 [label="[BatchSize,\nW=56, H=56, C=64"] dense1 [label="DenseBlock1\n[NLayers=6, BNSize=4,\n GrowthRate=32]"] featmap11 [label="[BatchSize, W=56, H=56,\n C=64+6*32=256]"] trans1 [label="Trasition1\n[CompRate=0.5]"] featmap12 [label="[BatchSize, W=28, H=28, C=128]"] dense2 [label="DenseBlock2\n[NLayers=12, BNSize=4,\n GrowthRate=32]"] featmap21 [label="[BatchSize, W=28, H=28,\n C=128+12*32=512]"] trans2 [label="Trasition2\n[CompRate=0.5]"] featmap22 [label="[BatchSize, W=14, H=14, C=256]"] dense3 [label="DenseBlock3\n[NLayers=24, BNSize=4,\n GrowthRate=32]"] featmap31 [label="[BatchSize, W=14, H=14,\n C=256+24*32=1024]"] trans3 [label="Trasition3\n[CompRate=0.5]"] featmap32 [label="[BatchSize, W=7, H=7, C=512]"] dense4 [label="DenseBlock4\n[NLayers=16, BNSize=4,\n GrowthRate=32]"] featmap4 [label="[BatchSize, W=7, H=7,\n C=512+16*32=1024]"] avgpool [label="AvgPool2D\n[K=7, S=7]"] featmap5 [label="[BatchSize, W=1, H=1, C=1024]"] reshape [label="reshape([1024])"] linear [label="Linear\n[1024, 1000"] softmax [label="Softmax"] oup [label="输出\n[BatchSize, 1000]"] inp -> conv0 -> bn0 -> relu0 -> maxpool0 -> featmap0 -> dense1 -> featmap11 -> trans1 -> featmap12 -> dense2 -> featmap21 -> trans2 -> featmap22 -> dense3 -> featmap31 -> trans3 -> featmap32 -> dense4 -> featmap4 -> avgpool -> featmap5 -> reshape -> linear -> softmax -> oup }
密集块:
digraph DenseBlock { rankdir=BT node [ style=filled, color=Black fontcolor=White, fillcolor="#30638e", fontname="SimHei", fontsize=32, width=7, height=2, shape="box", ] inp [label="输入\n[BatchSize, W=BlockW,\n H=BlockH, C=LayerIn]"] DenseLayers [label="DenseLayer x NLayers\n[In=BlockIN+#Layer*GrowthRate]"] oup [label="输出\n[BatchSize,\n W=BlockW, H=BlockH,\n C=LayerIn+NumLayer*GrowthRate ]"] inp -> DenseLayers -> oup }
密集层:
digraph DenseLayer { rankdir=BT node [ style=filled, color=Black fontcolor=White, fillcolor="#30638e", fontname="SimHei", fontsize=32, width=5, height=2, shape="box", ] inp [label="输入\n[BatchSize, W=BlockW,\n H=BlockH, C=LayerIn]"] bn1 [label="BatchNorm1(LayerIn)"] relu1 [label="Relu"] conv1 [label="Conv2D#1\n[K=1, In=LayerIn,\n Out=BNSize*GrowthRate]"] bn2 [label="BatchNorm2\n(BNSize*GrowthRate)"] relu2 [label="Relu"] conv2 [label="Conv2D#1\n[K=3, P=1,\n In=BNSize*GrowthRate,\n Out=GrowthRate]"] cat [label="cat(axis=1)"] oup [label="输出\n[BatchSize,\n W=BlockW, H=BlockH,\n C=LayerIn+GrowthRate]"] inp -> bn1 -> relu1 -> conv1 -> bn2 -> relu2 -> conv2 -> cat -> oup inp -> cat }
过渡块:
digraph TransitionLayer { rankdir=BT node [ style=filled, color=Black fontcolor=White, fillcolor="#30638e", fontname="SimHei", fontsize=32, width=5, height=2, shape="box", ] inp [label="输入\n[BatchSize, W=LayerW,\n H=LayerH, C=LayerIn]"] bn [label="BatchNorm1(LayerIn)"] relu [label="Relu"] conv [label="Conv2D\n[K=1, In=LayerIn,\n Out=LayerIn*CompRate]"] maxpool [label="MaxPool2D\n[K=2, S=2]"] oup [label="输出\n[BatchSize,\n W=BlockW/2,\n H=BlockH/2,\n C=LayerIn*CompRate]"] inp -> bn -> relu -> conv -> maxpool -> oup }
四、自编码器
4.1 栈式自编码器
digraph StackAutoEncoder { rankdir=BT node [ style=filled, color=Black fontcolor=White, fillcolor="#30638e", fontname="SimHei", fontsize=32, width=5, height=2, shape="box", ] inp [label="输入\n[BatchSize,\n NFeature(768)]", shape="Mrecord"] ll1 [label="Linear\n[NFeature(768),\n NHidden1(512)]"] σ1 [label="Sigmoid"] ll2 [label="Linear\n[NHidden1(512),\n NHidden2(256)]"] σ2 [label="Sigmoid"] ll3 [label="Linear\n[NHidden2(256),\n NHidden1(512)]"] σ3 [label="Sigmoid"] ll4 [label="Linear\n[NHidden1(512),\n NFeature(768)]"] oup [label="输出\n[BatchSise,\n NFeature(768)]", shape="Mrecord"] inp -> ll1 -> σ1 -> ll2 -> σ2 -> ll3 -> σ3 -> ll4 -> oup }
4.2 去噪自编码器
digraph DenoiseAutoEncoder { rankdir=BT node [ style=filled, color=Black fontcolor=White, fillcolor="#30638e", fontname="SimHei", fontsize=32, width=5, height=2, shape="box", ] inp [label="输入\n[BatchSize,\n NFeature(768)]", shape="Mrecord"] noise [label="AddNoise\n+ 0.5 * randn(\nBatchSize,\n NFeature(768))"] ll1 [label="Linear\n[NFeature(768),\n NHidden1(512)]"] σ1 [label="Sigmoid"] ll2 [label="Linear\n[NHidden1(512),\n NHidden2(256)]"] σ2 [label="Sigmoid"] ll3 [label="Linear\n[NHidden2(256),\n NHidden1(512)]"] σ3 [label="Sigmoid"] ll4 [label="Linear\n[NHidden1(512),\n NFeature(768)]"] oup [label="输出\n[BatchSize,\n NFeature(768)]", shape="Mrecord"] inp -> noise -> ll1 -> σ1 -> ll2 -> σ2 -> ll3 -> σ3 -> ll4 -> oup }
4.3 变分自编码器
digraph VariationAutoEncoder { rankdir=BT node [ style=filled, color=Black fontcolor=White, fillcolor="#30638e", fontname="SimHei", fontsize=32, width=5, height=2, shape="box", ] inp [label="输入\n[BatchSize,\n NFeature(768)]", shape="Mrecord"] ll1 [label="Linear\n[NFeature(768),\n NHidden1(512)]"] σ1 [label="Sigmoid"] ll2 [label="Linear\n[NHidden1(512),\n NHidden2(256)]"] σ2 [label="Sigmoid"] ll3_mean [label="Linear\n[NHidden2(256),\n NHidden3(128)]"] ll3_log_var [label="Linear\n[NHidden2(256),\n NHidden3(128)]"] z_mean [label="μ\n[BatchSize,\n NHidden3(128)]", shape="Mrecord"] z_log_var [label="logσ²\n[BatchSize,\n NHidden3(128)]", shape="Mrecord"] eps [label="ε\nrandn(BatchSize,\n NHidden3(128))", shape="Mrecord"] sample [label="μ + exp(logσ² / 2) * ε", width=7] z [label="z\n[BatchSize,\n NHidden3(128)]", shape="Mrecord"] ll4 [label="Linear\n[NHidden3(128),\n NHidden2(256)]"] σ4 [label="Sigmoid"] ll5 [label="Linear\n[NHidden2(256),\n NHidden1(512)]"] σ5 [label="Sigmoid"] ll6 [label="Linear\n[NHidden1(512),\n NFeature(768)]"] oup [label="输出\n[BatchSize,\n NFeature(768)]", shape="Mrecord"] inp -> ll1 -> σ1 -> ll2 -> σ2 σ2 -> ll3_mean -> z_mean -> sample σ2 -> ll3_log_var -> z_log_var -> sample eps -> sample -> z -> ll4 -> σ4 -> ll5 -> σ5 -> ll6 -> oup }
经典神经网络架构参考 v1.0(4)https://developer.aliyun.com/article/1489286