首页 > 其他 > 详细

tensor calculation numpy

时间:2020-06-11 23:01:16      阅读:74      评论:0      收藏:0      [点我收藏+]

>>> c = arange(20).reshape(5,4)
>>> c
array([[ 0, 1, 2, 3],
[ 4, 5, 6, 7],
[ 8, 9, 10, 11],
[12, 13, 14, 15],
[16, 17, 18, 19]])

c.shape[0]
5
Gives the number of rows

c.shape[1]
4
Gives number of columns

 

def naive_vector_dot(x, y):
  assert len(x.shape) == 1
  assert len(y.shape) == 1
  assert x.shape[0] == y.shape[0]
z = 0.
for i in range(x.shape[0]):
  z += x[i] * y[i]
return z

 

技术分享图片

 

高维度计算

(a, b, c, d) . (d,) -> (a, b, c)
(a, b, c, d) . (d, e) -> (a, b, c, e)

 

 

 

 

tensor calculation numpy

原文:https://www.cnblogs.com/lnas01/p/13096261.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!