This commit is contained in:
Dun Liang 2020-03-23 21:56:56 +08:00
commit 415aa4663d
4 changed files with 6 additions and 6 deletions

View File

@ -59,7 +59,7 @@ optim = nn.SGD (model.parameters(), learning_rate)
for i,(x,y) in enumerate(get_data(n)):
pred_y = model(x)
loss = ((pred_y - y)**2)
loss = jt.sqr(pred_y - y)
loss_mean = loss.mean()
optim.step (loss_mean)
print(f"step {i}, loss = {loss_mean.data.sum()}")

View File

@ -102,7 +102,7 @@ def conv(x, w):
])
ww = w.broadcast_var(xx)
yy = xx*ww
y = yy.sum([3,4,5]) # Kh, Kw, Kc
y = yy.sum([3,4,5]) # Kh, Kw, c
return y
# Let's disable tuner. This will cause jittor not to use mkl for convolution
@ -150,7 +150,7 @@ xx = x.reindex([N,H-Kh+1,W-Kw+1,Kh,Kw,C,Kc], [
])
ww = w.broadcast_var(xx)
yy = xx*ww
y = yy.sum([3,4,5]) # Kh, Kw, Kc
y = yy.sum([3,4,5]) # Kh, Kw, C
```
**After expansion:**

View File

@ -21,7 +21,7 @@ def conv(x, w):
])
ww = w.broadcast_var(xx)
yy = xx*ww
y = yy.sum([3,4,5]) # Kh, Kw, Kc
y = yy.sum([3,4,5]) # Kh, Kw, C
return y, yy
def conv_naive(x, w):
@ -52,7 +52,7 @@ def conv_transpose(x, w):
], 0, ['(i1-i3)%2', '(i2-i4)%2'])
ww = w.broadcast_var(xx)
yy = xx*ww
y = yy.sum([3,4,5]) # Kh, Kw, Kc
y = yy.sum([3,4,5]) # Kh, Kw, C
return y, yy
def conv_transpose_naive(x, w):

View File

@ -86,7 +86,7 @@ struct ReindexOp : Op {
])
ww = w.broadcast_var(xx)
yy = xx*ww
y = yy.sum([3,4,5]) # Kh, Kw, Kc
y = yy.sum([3,4,5]) # Kh, Kw, C
return y, yy
```
*/