标签:usr code orm creat rand cpu created .data form
#!/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]]
<NDArray 2x4 @cpu(0)>
(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]]
<NDArray 3x4 @cpu(0)>
标签:usr code orm creat rand cpu created .data form
原文地址:http://blog.51cto.com/13959448/2316515