import numpy as np
# Create your (10, 5) array (10 samples with 5 features)
array_10x5 = np.random.rand(10, 5)
# Create your single sample (1, 5)
single_sample = np.random.rand(1, 5)
# Multiply the entire (10, 5) array with the single sample using broadcasting
result = np.sum(array_10x5 * single_sample, axis=1)
# result is now a (10,) array where each element corresponds to the sum of the
element-wise products
print(result)
2条答案
按热度按时间rdlzhqv91#
字符串
bmp9r5qi2#
字符串
我根据你所说的理解写了这段代码。这是你想要的输出吗?