numpy的multiply和*什么区别?具体讲讲multiply 10
a=mat([[1,2,3,4,5]])b=mat([[1],[2],[3],[4],[5]])printshape(a)#(1,5)printshape(b)#(5,1...
a = mat(
[
[1,2,3,4,5]
]
)
b = mat(
[
[1],[2],[3],[4],[5]
]
)
print shape(a) #(1, 5)
print shape(b) #(5, 1)
c1 = multiply(a,b)
# 1*5 5*1
print c1
'''
[[ 1 2 3 4 5]
[ 2 4 6 8 10]
[ 3 6 9 12 15]
[ 4 8 12 16 20]
[ 5 10 15 20 25]]
'''
c2 = multiply(b,a)
'''
[[ 1 2 3 4 5]
[ 2 4 6 8 10]
[ 3 6 9 12 15]
[ 4 8 12 16 20]
[ 5 10 15 20 25]]
'''
print c2
d1 = a*b
print d1 #[[55]]
d2 = b*a
print d2
'''
[[ 1 2 3 4 5]
[ 2 4 6 8 10]
[ 3 6 9 12 15]
[ 4 8 12 16 20]
[ 5 10 15 20 25]]
'''
print multiply(3,2) #6
为什么c1和c2输出结果是相同的?请具体讲讲multiply,谢谢!!! 展开
[
[1,2,3,4,5]
]
)
b = mat(
[
[1],[2],[3],[4],[5]
]
)
print shape(a) #(1, 5)
print shape(b) #(5, 1)
c1 = multiply(a,b)
# 1*5 5*1
print c1
'''
[[ 1 2 3 4 5]
[ 2 4 6 8 10]
[ 3 6 9 12 15]
[ 4 8 12 16 20]
[ 5 10 15 20 25]]
'''
c2 = multiply(b,a)
'''
[[ 1 2 3 4 5]
[ 2 4 6 8 10]
[ 3 6 9 12 15]
[ 4 8 12 16 20]
[ 5 10 15 20 25]]
'''
print c2
d1 = a*b
print d1 #[[55]]
d2 = b*a
print d2
'''
[[ 1 2 3 4 5]
[ 2 4 6 8 10]
[ 3 6 9 12 15]
[ 4 8 12 16 20]
[ 5 10 15 20 25]]
'''
print multiply(3,2) #6
为什么c1和c2输出结果是相同的?请具体讲讲multiply,谢谢!!! 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询