How to use numpy's "prod" function



Python
library
pip

MeCab

numpy
digitize

mgrid

pad

polyfit

prod

shape

matplotlib
figure

pcolormesh

scatter

pytorch
BCELoss, MSELoss

device

Embedding

TensorDataset, Dataloader

RNN, LSTM
scikit-learn
SVC

scipy
interpolate
tkinter
postscript

image display

frame, grid

other
linear interpolation

OpenAI gym
CartPole-v0


Release date:2022/6/19         

In Japanese


■Description of the prod function

Do the product of the arrays.

■Specific example using prod function

import numpy as np

a = np.array([[5, 50, 10],[20,-10,1]])
np.prod(a) # Product of all elements

 ⇒ -500000 # 5*50*10*20*-10*1

np.prod(a,axis=0) # Product of elements between columns

 ⇒ array([ 100, -500, 10]) # [5*20, 50*-10 , 10*1]

np.prod(a,axis=1) # Product of elements between rows

 ⇒ array([2500, -200]) # [5*50*10 , 20*-10*1]










List of related articles



Python
library
pip

MeCab

numpy
digitize

mgrid

pad

polyfit

prod

shape

matplotlib
figure

pcolormesh

scatter

pytorch
BCELoss, MSELoss

device

Embedding

TensorDataset, Dataloader

RNN, LSTM
scikit-learn
SVC

scipy
interpolate
tkinter
postscript

image display

frame, grid

other
linear interpolation

OpenAI gym
CartPole-v0