Look at the code and see this method. Record it. This is the link to their official website np.correlate.
What is unclear is actually the dot multiplication of two arrays. The different modes are misplaced dot multiplications. Just look at the code.
a is the original array, v is the filter, corresponding to multiplication
import numpy as np
mode0 = 'same'
mode1 = 'valid'
mode2 = 'full'
a = [1, 2, 3]
v = [1, 2]
print(np.correlate(a, v, mode0))
print(np.correlate(a, v, mode1))
print(np.correlate(a, v, mode2))
# 结果
[2 5 8]
[5 8]
[2 5 8 3]
a = [1, 2, 3]
v = [1, 2, 3]
print(np.correlate(a, v, mode0))
print(np.correlate(a, v, mode1))
print(np.correlate(a, v, mode2))
# 结果
[ 8 14 8]
[14]
[ 3 8 14 8 3]
a = [1, 2, 3, 4]
v = [1, 2]
print(np.correlate(a, v, mode0))
print(np.correlate(a, v, mode1))
print(np.correlate(a, v, mode2))
# 结果
[ 2 5 8 11]
[ 5 8 11]
[ 2 5 8 11 4]