mxnet数据操作


#
coding: utf-8 # In[2]: from mxnet import nd # In[3]: x = nd.arange(12) x # In[4]: x.shape,x.size # In[5]: x.shape # In[6]: x.size # In[7]: x = x.reshape((3,4)) x # In[9]: x = x.reshape((2,-1)) x # In[11]: x = x.reshape((3,-1)) x # In[12]: nd.zeros((2,3,4)) # In[13]: nd.ones((3,4)) # In[14]: nd.random.normal(0,1,shape=(3,4)) # In[15]: y = nd.array([[2,1,4,3],[1,2,3,4],[4,3,2,1]]) y # In[16]: x+y # In[17]: x*y,x/y # In[20]: nd.exp(y) # In[21]: y.T # In[22]: nd.dot(x,y.T) # In[23]: x == y # In[24]: x >= y # In[25]: x.sum() # In[26]: x.norm() # In[27]: x.norm().asscalar() # In[28]: import numpy as np p = np.ones((2,3)) d = nd.array(p) d # In[29]: d.asnumpy() # In[30]: a = nd.arange(3).reshape((-1,1)) # In[32]: b = nd.arange(2).reshape((1,-1)) a,b # In[33]: a + b

范数:n 维向量 (x1,x2,x3,...,xn)T 的 Lp 范数为:

L1范数:各元素绝对值之和

L2范数:各元素平方开根号 (nd.norm())

矩阵的 Frobenius范数为个元素平方和开根号

原文地址:https://www.cnblogs.com/TreeDream/p/9993619.html