質問編集履歴

1

コード削除

2021/12/21 05:32

投稿

ttt.k
ttt.k

score3

test CHANGED
File without changes
test CHANGED
@@ -5,71 +5,3 @@
5
5
  Tensor for 'out' is on CPU, Tensor for argument #1 'self' is on CPU, but expected them to be on GPU (while checking arguments for addmm)
6
6
 
7
7
  ```
8
-
9
-
10
-
11
- ```python
12
-
13
- def train(net, trainloader, NUM_EPOCHS):
14
-
15
- train_loss = []
16
-
17
- for epoch in range(NUM_EPOCHS):
18
-
19
- running_loss = 0.0
20
-
21
- optimizer.zero_grad()
22
-
23
- outputs = net(trainset)
24
-
25
- loss = criterion(outputs, trainset)
26
-
27
- loss.backward()
28
-
29
- optimizer.step()
30
-
31
- loss = running_loss / len(trainloader)
32
-
33
- train_loss.append(loss)
34
-
35
- print('Epoch {} of {}, Train Loss: {:.3f}'.format(
36
-
37
- epoch+1, NUM_EPOCHS, loss))
38
-
39
- save_decoded_image(img_noisy.cpu().data, name='./Saved_Images/noisy{}.png'.format(epoch))
40
-
41
- save_decoded_image(outputs.cpu().data, name='./Saved_Images/denoised{}.png'.format(epoch))
42
-
43
- return train_loss
44
-
45
-
46
-
47
-
48
-
49
- # the loss function
50
-
51
- criterion = nn.MSELoss()
52
-
53
- # the optimizer
54
-
55
- optimizer = optim.Adam(net.parameters(), lr=LEARNING_RATE)
56
-
57
-
58
-
59
-
60
-
61
-
62
-
63
- device = get_device()
64
-
65
- print(device)
66
-
67
- #torch.tensor(device)
68
-
69
- net.to(device)
70
-
71
- make_dir()
72
-
73
- train_loss = train(net, trainloader, NUM_EPOCHS)
74
-
75
- ```