Esempio n. 1
0
tar_y = Tensor(v)

mse = MSE_Loss()
for e in range(0):
    y = conv2d.forward(input,
                       k,
                       kx=kx,
                       ky=ky,
                       kz=kz,
                       channel=channel,
                       stride=(sx, sy, sz))
    loss = mse(y, tar_y, (0, 1, 2, 3))
    loss.backward()
    k.value -= k.gradient * 0.000001
    #print(k.gradient)
    k.zero_grad()

    #input.value -= input.gradient * 0.001
    #print(input.gradient)
    #input.zero_grad()

    print(e, loss.item())
print(tar_y - y)
print(input)
print(k)

from np.ad.operation import conv2d_transpose

cx = 2
cy = 2
cz = 2
Esempio n. 2
0
           [24.0, 32.0],
           [48.0, 56.0]])
tar.append([[24.0, 32.0],
           [48.0, 56.0],
           [48.0, 64.0],
           [56.0, 112.0]])
target = Tensor(np.array(tar))

mse = MSE_Loss()
for e in range(30000):
    y = conv1d.forward(input, k, kx=2, ky=2, channel=2, stride=(1, 1))
    loss = mse(y, target, (0, 1, 2))
    loss.backward()
    k.value -= k.gradient * 0.0001
    #print(k.gradient)
    k.zero_grad()

    input.value -= input.gradient * 0.001
    #print(input.gradient)
    input.zero_grad()

    print(loss.item())
print(y)
print(input)
print(k)

from np.ad.operation import conv1d_transpose

inp = []

inp.append([[1.0, 1.0, 1.0],