@@ -65,7 +65,7 @@ def __init__(self):
65
65
out_channels = 16 , # n_filters
66
66
kernel_size = 5 , # filter size
67
67
stride = 1 , # filter movement/step
68
- padding = 2 , # if want same width and length of this image after con2d , padding=(kernel_size-1)/2 if stride=1
68
+ padding = 2 , # if want same width and length of this image after Conv2d , padding=(kernel_size-1)/2 if stride=1
69
69
), # output shape (16, 28, 28)
70
70
nn .ReLU (), # activation
71
71
nn .MaxPool2d (kernel_size = 2 ), # choose max value in 2x2 area, output shape (16, 14, 14)
@@ -115,7 +115,7 @@ def plot_with_labels(lowDWeights, labels):
115
115
116
116
if step % 50 == 0 :
117
117
test_output , last_layer = cnn (test_x )
118
- pred_y = torch .max (test_output , 1 )[1 ].data .squeeze (). numpy ()
118
+ pred_y = torch .max (test_output , 1 )[1 ].data .numpy ()
119
119
accuracy = float ((pred_y == test_y .data .numpy ()).astype (int ).sum ()) / float (test_y .size (0 ))
120
120
print ('Epoch: ' , epoch , '| train loss: %.4f' % loss .data .numpy (), '| test accuracy: %.2f' % accuracy )
121
121
if HAS_SK :
@@ -129,6 +129,6 @@ def plot_with_labels(lowDWeights, labels):
129
129
130
130
# print 10 predictions from test data
131
131
test_output , _ = cnn (test_x [:10 ])
132
- pred_y = torch .max (test_output , 1 )[1 ].data .numpy (). squeeze ()
132
+ pred_y = torch .max (test_output , 1 )[1 ].data .numpy ()
133
133
print (pred_y , 'prediction number' )
134
134
print (test_y [:10 ].numpy (), 'real number' )
0 commit comments