mxnet随笔-Dense

#!/usr/bin/env python2
# -*- coding: utf-8 -*-
"""
Created on Fri Aug 10 16:13:29 2018

@author: myhaspl
"""
from mxnet import nd
from mxnet.gluon import nn
layer = nn.Dense(2)#输出
layer.initialize()
x = nd.random.uniform(-1,1,(3,4))#输入3组数据
layer(x)
w=layer.weight.data()#权值,数据为4个元素,因此权值也是4个元素
print w
print w.shape
print x

[[-0.00873779 -0.02834515 0.05484822 -0.06206018]
[ 0.06491279 -0.03182812 -0.01631819 -0.00312688]]

(2L, 4L)

[[ 0.09762704 0.18568921 0.43037868 0.6885315 ]
[ 0.20552671 0.71589124 0.08976638 0.6945034 ]
[-0.15269041 0.24712741 0.29178822 -0.23123658]]

你可能感兴趣的:(AI)