-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun.py
More file actions
27 lines (21 loc) · 648 Bytes
/
run.py
File metadata and controls
27 lines (21 loc) · 648 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import numpy as np
from convolution import Conv2D
in_channels = 3
out_channels = 128
kernel_size = 3
stride = 2
padding = 1
batch_size = (4, in_channels, 12, 10)
dout_size = (4, out_channels, 6, 5)
np.random.seed(42)
x = np.random.random(batch_size) # create data for forward pass
dout = np.random.random(dout_size) # create random data for backward
print('x: ', x.shape)
print('d_out: ', dout.shape)
conv = Conv2D(in_channels, out_channels, kernel_size, stride, padding)
conv_out = conv.forward(x)
print('conv_out: ', conv_out.shape)
db, dw, dx = conv.backward(dout)
print('db: ', db.shape)
print('dw: ', dw.shape)
print('dx: ', dx.shape)