How to use numpy's "prod" function



Python
library
pip

MeCab

Common
class

pickle

read/readline

numpy
asfarray

digitize

expit

linalg.solve

meshgrid

mgrid

ndmin

pad

poly1d

polyfit

prod

shape

matplotlib
figure

pcolormesh

scatter

pytorch
BCELoss, MSELoss

device

Embedding

TensorDataset, Dataloader

RNN, LSTM
scikit-learn
SVC

GaussianNB

scipy
interpolate
tkinter
postscript

image display

frame, grid

Crop Image

other
linear interpolation

Hysteresis switch

Square/Triangle wave

OpenAI gym
CartPole-v0

By purpose
1 of K Coding


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

Common
class

pickle

read/readline

numpy
asfarray

digitize

expit

linalg.solve

meshgrid

mgrid

ndmin

pad

poly1d

polyfit

prod

shape

matplotlib
figure

pcolormesh

scatter

pytorch
BCELoss, MSELoss

device

Embedding

TensorDataset, Dataloader

RNN, LSTM
scikit-learn
SVC

GaussianNB

scipy
interpolate
tkinter
postscript

image display

frame, grid

Crop Image

other
linear interpolation

Hysteresis switch

Square/Triangle wave

OpenAI gym
CartPole-v0

By purpose
1 of K Coding