我想通过从 0 到 5 的递增幂来提高向量:
import numpy as np
a = np.array([1, 2, 3]) # list of 11 components
b = np.array([0, 1, 2, 3, 4]) # power
c = np.power(a,b)
Run Code Online (Sandbox Code Playgroud)
期望的结果是:
c = [[1**0, 1**1, 1**2, 1**3, 1**4], [2**0, 2**1, ...], ...]
Run Code Online (Sandbox Code Playgroud)
我不断收到此错误:
ValueError: operands could not be broadcast together with shapes (3,) (5,)
Run Code Online (Sandbox Code Playgroud)