Skip to content

Commit 6d3a56f

Browse files
committed
add nlp model.
1 parent 3dece2b commit 6d3a56f

11 files changed

Lines changed: 5709 additions & 212 deletions

20pytorch/02.variable.py

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,33 @@
2323

2424
print('y = y * 2 result:')
2525
x = torch.randn(3)
26-
print('raw x:',x)
26+
print('raw x:', x)
2727
x = Variable(x, requires_grad=True)
2828
y = x * 2
29-
while y.data.norm() < 1000:
29+
while y.data.norm() < 10:
3030
y = y * 2
3131
print(y)
32+
33+
print('*' * 43)
34+
a = torch.randn(1, 3)
35+
print('a:', a, a.shape)
36+
b = torch.rand(1, 3)
37+
print('b:', b, b.shape)
38+
39+
aa = torch.unsqueeze(a, 1)
40+
print('aa:', aa, aa.shape)
41+
bb = torch.unsqueeze(a, 0)
42+
print('bb:', bb, bb.shape)
43+
print('a:', a, a.shape)
44+
dd = a.unsqueeze(0)
45+
print('a unsqueeze:', a, a.shape)
46+
print('dd:', dd, dd.shape)
47+
48+
c = dd.squeeze(0)
49+
print('c:', c, dd, c.shape, dd.shape)
50+
d = torch.squeeze(dd, 0)
51+
print('d:', d, d.shape)
52+
e = dd.squeeze()
53+
print('dd:', dd.shape, dd, e, e.shape)
54+
f = dd.squeeze(0)
55+
print('f:', f, f.shape)

0 commit comments

Comments
 (0)