分享web开发知识

注册/登录|最近发布|今日推荐

主页 IT知识网页技术软件开发前端开发代码编程运营维护技术分享教程案例
当前位置:首页 > 运营维护

mxnet-Sequential

发布时间:2023-09-06 02:22责任编辑:蔡小小关键词:暂无标签
#!/usr/bin/env python2# -*- coding: utf-8 -*-"""Created on Fri Aug 10 16:13:29 2018@author: myhaspl"""from mxnet import ndfrom mxnet.gluon import nnnet = nn.Sequential()# Add a sequence of layers.net.add(# Similar to Dense, it is not necessary to specify the# input channels by the argument `in_channels`, which will be # automatically inferred in the first forward pass. Also,# we apply a relu activation on the output.## In addition, we can use a tuple to specify a# non-square kernel size, such as `kernel_size=(2,4)nn.Conv2D(channels=6, kernel_size=5, activation=‘relu‘),# One can also use a tuple to specify non-symmetric# pool and stride sizesnn.MaxPool2D(pool_size=2, strides=2),nn.Conv2D(channels=16, kernel_size=3, activation=‘relu‘), nn.MaxPool2D(pool_size=2, strides=2),# flatten the 4-D input into 2-D with shape# `(x.shape[0], x.size/x.shape[0])` so that it can be used# by the following dense layersnn.Flatten(),nn.Dense(120, activation="relu"),nn.Dense(84, activation="relu"),nn.Dense(10))print netnet.initialize()x = nd.random.uniform(shape=(4,1,28,28))y = net(x)print y.shapeprint net[0].weight.data().shapeprint net[7].weight.data().shapeSequential(? (0): Conv2D(None -> 6, kernel_size=(5, 5), stride=(1, 1))? (1): MaxPool2D(size=(2, 2), stride=(2, 2), padding=(0, 0), ceil_mode=False)? (2): Conv2D(None -> 16, kernel_size=(3, 3), stride=(1, 1))? (3): MaxPool2D(size=(2, 2), stride=(2, 2), padding=(0, 0), ceil_mode=False)? (4): Flatten? (5): Dense(None -> 120, Activation(relu))? (6): Dense(None -> 84, Activation(relu))? (7): Dense(None -> 10, linear))

(4L, 10L)
(6L, 1L, 5L, 5L)
(10L, 84L)

mxnet-Sequential

原文地址:http://blog.51cto.com/13959448/2316507

知识推荐

我的编程学习网——分享web前端后端开发技术知识。 垃圾信息处理邮箱 tousu563@163.com 网站地图
icp备案号 闽ICP备2023006418号-8 不良信息举报平台 互联网安全管理备案 Copyright 2023 www.wodecom.cn All Rights Reserved