## **pytorch DNN strategy**

```python
'''
导入DNN需要的库
'''
import torch
from torch.autograd import Variable  # 将多维矩阵放入Variable，可以反向传播
import torch.nn as nn  #参数扩展，计算权重
import torch.nn.functional as F
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from sklearn.metrics import accuracy_score  #评价测试结果，所有分类正确的百分比
from torchvision import datasets
from torchvision import transforms
from tensorflow import keras
import sympy
from sympy import Matrix
import tushare as ts

%config INlineBackend.figure_format='svg' #  为了让数字更清晰的显示在notebook中
```

```python
torch.cuda.is_available()
```

    False

```python
'''
获取数据
'''
data = ts.get_k_data('hs300',start = '2014-07-01',end = '2021-01-20')
data.set_index('date',inplace=True)
data
```

    本接口即将停止更新，请尽快使用Pro版接口：https://waditu.com/document/2

      open
      close
      high
      low
      volume
      code

      date

      2014-07-01
      2169.20
      2164.56
      2171.15
      2157.13
      53323100.0
      hs300

      2014-07-02
      2164.00
      2170.87
      2171.51
      2155.61
      59685501.0
      hs300

      2014-07-03
      2169.00
      2180.19
      2184.96
      2164.84
      63690690.0
      hs300

      2014-07-04
      2180.45
      2178.70
      2183.80
      2174.07
      52851106.0
      hs300

      2014-07-07
      2178.55
      2176.29
      2186.20
      2171.08
      50242334.0
      hs300

      ...
      ...
      ...
      ...
      ...
      ...
      ...

      2021-01-14
      5556.21
      5470.46
      5568.02
      5458.68
      243683380.0
      hs300

      2021-01-15
      5471.39
      5458.08
      5500.63
      5390.27
      238637435.0
      hs300

      2021-01-18
      5438.16
      5518.52
      5541.46
      5410.78
      207051869.0
      hs300

      2021-01-19
      5525.97
      5437.52
      5532.48
      5415.72
      211043425.0
      hs300

      2021-01-20
      5439.91
      5476.43
      5496.05
      5426.54
      170913260.0
      hs300

1601 rows × 6 columns

```python
'''
获取因子
收益率标签为1天的
'''
data_cleaned = pd.DataFrame()
data_cleaned['Close0'] = np.log(data['close'])
data_cleaned['H_L'] = data['high']-data['low']
data_cleaned['C_O'] = data['close']-data['open']
data_cleaned['volume'] = np.log10(data['volume'])

data_cleaned['Close1'] = data_cleaned['Close0'].shift(1)
data_cleaned['Close2'] = data_cleaned['Close0'].shift(2)
data_cleaned['Close3'] = data_cleaned['Close0'].shift(3)
data_cleaned['Close4'] = data_cleaned['Close0'].shift(4)
data_cleaned['Close5'] = data_cleaned['Close0'].shift(5)

data_cleaned['H_L1'] = data_cleaned['H_L'].shift(1)
data_cleaned['H_L2'] = data_cleaned['H_L'].shift(2)
data_cleaned['H_L3'] = data_cleaned['H_L'].shift(3)
data_cleaned['H_L4'] = data_cleaned['H_L'].shift(4)
data_cleaned['H_L5'] = data_cleaned['H_L'].shift(5)

data_cleaned['C_O1'] = data_cleaned['C_O'].shift(1)
data_cleaned['C_O2'] = data_cleaned['C_O'].shift(2)
data_cleaned['C_O3'] = data_cleaned['C_O'].shift(3)
data_cleaned['C_O4'] = data_cleaned['C_O'].shift(4)
data_cleaned['C_O5'] = data_cleaned['C_O'].shift(5)

data_cleaned['volume1'] = data_cleaned['volume'].shift(1)
data_cleaned['volume2'] = data_cleaned['volume'].shift(2)
data_cleaned['volume3'] = data_cleaned['volume'].shift(3)
data_cleaned['volume4'] = data_cleaned['volume'].shift(4)
data_cleaned['volume5'] = data_cleaned['volume'].shift(5)

data_cleaned['Close0_shift(-1)'] = data_cleaned['Close0'].shift(-1)
data_cleaned['label'] =0.5 + 0.5*np.sign(data_cleaned['Close0_shift(-1)']-data_cleaned['Close0'])
data_cleaned.head(23)
```

      Close0
      H_L
      C_O
      volume
      Close1
      Close2
      Close3
      Close4
      Close5
      H_L1
      ...
      C_O3
      C_O4
      C_O5
      volume1
      volume2
      volume3
      volume4
      volume5
      Close0_shift(-1)
      label

      date

      2014-07-01
      7.679972
      14.02
      -4.64
      7.726915
      NaN
      NaN
      NaN
      NaN
      NaN
      NaN
      ...
      NaN
      NaN
      NaN
      NaN
      NaN
      NaN
      NaN
      NaN
      7.682883
      1.0

      2014-07-02
      7.682883
      15.90
      6.87
      7.775869
      7.679972
      NaN
      NaN
      NaN
      NaN
      14.02
      ...
      NaN
      NaN
      NaN
      7.726915
      NaN
      NaN
      NaN
      NaN
      7.687167
      1.0

      2014-07-03
      7.687167
      20.12
      11.19
      7.804076
      7.682883
      7.679972
      NaN
      NaN
      NaN
      15.90
      ...
      NaN
      NaN
      NaN
      7.775869
      7.726915
      NaN
      NaN
      NaN
      7.686484
      0.0

      2014-07-04
      7.686484
      9.73
      -1.75
      7.723054
      7.687167
      7.682883
      7.679972
      NaN
      NaN
      20.12
      ...
      -4.64
      NaN
      NaN
      7.804076
      7.775869
      7.726915
      NaN
      NaN
      7.685377
      0.0

      2014-07-07
      7.685377
      15.12
      -2.26
      7.701070
      7.686484
      7.687167
      7.682883
      7.679972
      NaN
      9.73
      ...
      6.87
      -4.64
      NaN
      7.723054
      7.804076
      7.775869
      7.726915
      NaN
      7.687296
      1.0

      2014-07-08
      7.687296
      17.42
      5.64
      7.705381
      7.685377
      7.686484
      7.687167
      7.682883
      7.679972
      15.12
      ...
      11.19
      6.87
      -4.64
      7.701070
      7.723054
      7.804076
      7.775869
      7.726915
      7.672623
      0.0

      2014-07-09
      7.672623
      30.25
      -29.43
      7.792546
      7.687296
      7.685377
      7.686484
      7.687167
      7.682883
      17.42
      ...
      -1.75
      11.19
      6.87
      7.705381
      7.701070
      7.723054
      7.804076
      7.775869
      7.669892
      0.0

      2014-07-10
      7.669892
      12.25
      -3.75
      7.746109
      7.672623
      7.687296
      7.685377
      7.686484
      7.687167
      30.25
      ...
      -2.26
      -1.75
      11.19
      7.792546
      7.705381
      7.701070
      7.723054
      7.804076
      7.672297
      1.0

      2014-07-11
      7.672297
      19.95
      11.69
      7.787986
      7.669892
      7.672623
      7.687296
      7.685377
      7.686484
      12.25
      ...
      5.64
      -2.26
      -1.75
      7.746109
      7.792546
      7.705381
      7.701070
      7.723054
      7.683293
      1.0

      2014-07-14
      7.683293
      26.62
      22.22
      7.820588
      7.672297
      7.669892
      7.672623
      7.687296
      7.685377
      19.95
      ...
      -29.43
      5.64
      -2.26
      7.787986
      7.746109
      7.792546
      7.705381
      7.701070
      7.684775
      1.0

      2014-07-15
      7.684775
      11.06
      4.89
      7.856219
      7.683293
      7.672297
      7.669892
      7.672623
      7.687296
      26.62
      ...
      -3.75
      -29.43
      5.64
      7.820588
      7.787986
      7.746109
      7.792546
      7.705381
      7.682883
      0.0

      2014-07-16
      7.682883
      16.48
      -1.95
      7.911478
      7.684775
      7.683293
      7.672297
      7.669892
      7.672623
      11.06
      ...
      11.69
      -3.75
      -29.43
      7.856219
      7.820588
      7.787986
      7.746109
      7.792546
      7.676506
      0.0

      2014-07-17
      7.676506
      19.85
      -9.76
      7.774178
      7.682883
      7.684775
      7.683293
      7.672297
      7.669892
      16.48
      ...
      22.22
      11.69
      -3.75
      7.911478
      7.856219
      7.820588
      7.787986
      7.746109
      7.679778
      1.0

      2014-07-18
      7.679778
      30.87
      16.48
      7.816064
      7.676506
      7.682883
      7.684775
      7.683293
      7.672297
      19.85
      ...
      4.89
      22.22
      11.69
      7.774178
      7.911478
      7.856219
      7.820588
      7.787986
      7.680771
      1.0

      2014-07-21
      7.680771
      12.98
      2.07
      7.733777
      7.679778
      7.676506
      7.682883
      7.684775
      7.683293
      30.87
      ...
      -1.95
      4.89
      22.22
      7.816064
      7.774178
      7.911478
      7.856219
      7.820588
      7.692889
      1.0

      2014-07-22
      7.692889
      35.35
      30.26
      7.895105
      7.680771
      7.679778
      7.676506
      7.682883
      7.684775
      12.98
      ...
      -9.76
      -1.95
      4.89
      7.733777
      7.816064
      7.774178
      7.911478
      7.856219
      7.695226
      1.0

      2014-07-23
      7.695226
      19.73
      6.44
      7.925384
      7.692889
      7.680771
      7.679778
      7.676506
      7.682883
      35.35
      ...
      16.48
      -9.76
      -1.95
      7.895105
      7.733777
      7.816064
      7.774178
      7.911478
      7.712895
      1.0

      2014-07-24
      7.712895
      39.98
      37.18
      8.077134
      7.695226
      7.692889
      7.680771
      7.679778
      7.676506
      19.73
      ...
      2.07
      16.48
      -9.76
      7.925384
      7.895105
      7.733777
      7.816064
      7.774178
      7.723319
      1.0

      2014-07-25
      7.723319
      21.82
      17.38
      7.995516
      7.712895
      7.695226
      7.692889
      7.680771
      7.679778
      39.98
      ...
      30.26
      2.07
      16.48
      8.077134
      7.925384
      7.895105
      7.733777
      7.816064
      7.751002
      1.0

      2014-07-28
      7.751002
      59.09
      51.52
      8.254957
      7.723319
      7.712895
      7.695226
      7.692889
      7.680771
      21.82
      ...
      6.44
      30.26
      2.07
      7.995516
      8.077134
      7.925384
      7.895105
      7.733777
      7.754211
      1.0

      2014-07-29
      7.754211
      26.55
      5.33
      8.127978
      7.751002
      7.723319
      7.712895
      7.695226
      7.692889
      59.09
      ...
      37.18
      6.44
      30.26
      8.254957
      7.995516
      8.077134
      7.925384
      7.895105
      7.750188
      0.0

      2014-07-30
      7.750188
      22.98
      -2.68
      8.089986
      7.754211
      7.751002
      7.723319
      7.712895
      7.695226
      26.55
      ...
      17.38
      37.18
      6.44
      8.127978
      8.254957
      7.995516
      8.077134
      7.925384
      7.762277
      1.0

      2014-07-31
      7.762277
      33.97
      28.28
      8.045275
      7.750188
      7.754211
      7.751002
      7.723319
      7.712895
      22.98
      ...
      51.52
      17.38
      37.18
      8.089986
      8.127978
      8.254957
      7.995516
      8.077134
      7.753366
      0.0

23 rows × 26 columns

```python
# 去掉多余的数据和空值
data_cleaned.dropna(inplace=True)
data_cleaned.drop(['Close0_shift(-1)'],axis=1,inplace=True)
data_cleaned
```

      Close0
      H_L
      C_O
      volume
      Close1
      Close2
      Close3
      Close4
      Close5
      H_L1
      ...
      C_O2
      C_O3
      C_O4
      C_O5
      volume1
      volume2
      volume3
      volume4
      volume5
      label

      date

      2014-07-08
      7.687296
      17.42
      5.64
      7.705381
      7.685377
      7.686484
      7.687167
      7.682883
      7.679972
      15.12
      ...
      -1.75
      11.19
      6.87
      -4.64
      7.701070
      7.723054
      7.804076
      7.775869
      7.726915
      0.0

      2014-07-09
      7.672623
      30.25
      -29.43
      7.792546
      7.687296
      7.685377
      7.686484
      7.687167
      7.682883
      17.42
      ...
      -2.26
      -1.75
      11.19
      6.87
      7.705381
      7.701070
      7.723054
      7.804076
      7.775869
      0.0

      2014-07-10
      7.669892
      12.25
      -3.75
      7.746109
      7.672623
      7.687296
      7.685377
      7.686484
      7.687167
      30.25
      ...
      5.64
      -2.26
      -1.75
      11.19
      7.792546
      7.705381
      7.701070
      7.723054
      7.804076
      1.0

      2014-07-11
      7.672297
      19.95
      11.69
      7.787986
      7.669892
      7.672623
      7.687296
      7.685377
      7.686484
      12.25
      ...
      -29.43
      5.64
      -2.26
      -1.75
      7.746109
      7.792546
      7.705381
      7.701070
      7.723054
      1.0

      2014-07-14
      7.683293
      26.62
      22.22
      7.820588
      7.672297
      7.669892
      7.672623
      7.687296
      7.685377
      19.95
      ...
      -3.75
      -29.43
      5.64
      -2.26
      7.787986
      7.746109
      7.792546
      7.705381
      7.701070
      1.0

      ...
      ...
      ...
      ...
      ...
      ...
      ...
      ...
      ...
      ...
      ...
      ...
      ...
      ...
      ...
      ...
      ...
      ...
      ...
      ...
      ...
      ...

      2021-01-13
      8.626580
      109.58
      -31.29
      8.417588
      8.629870
      8.601748
      8.611672
      8.614984
      8.597421
      178.72
      ...
      -63.08
      -30.86
      85.27
      31.16
      8.350675
      8.365181
      8.310321
      8.342170
      8.287294
      0.0

      2021-01-14
      8.607118
      109.34
      -85.75
      8.386826
      8.626580
      8.629870
      8.601748
      8.611672
      8.614984
      109.58
      ...
      176.85
      -63.08
      -30.86
      85.27
      8.417588
      8.350675
      8.365181
      8.310321
      8.342170
      0.0

      2021-01-15
      8.604852
      110.36
      -13.31
      8.377739
      8.607118
      8.626580
      8.629870
      8.601748
      8.611672
      109.34
      ...
      -31.29
      176.85
      -63.08
      -30.86
      8.386826
      8.417588
      8.350675
      8.365181
      8.310321
      1.0

      2021-01-18
      8.615865
      130.68
      80.36
      8.316079
      8.604852
      8.607118
      8.626580
      8.629870
      8.601748
      110.36
      ...
      -85.75
      -31.29
      176.85
      -63.08
      8.377739
      8.386826
      8.417588
      8.350675
      8.365181
      0.0

      2021-01-19
      8.601078
      116.76
      -88.45
      8.324372
      8.615865
      8.604852
      8.607118
      8.626580
      8.629870
      130.68
      ...
      -13.31
      -85.75
      -31.29
      176.85
      8.316079
      8.377739
      8.386826
      8.417588
      8.350675
      1.0

1595 rows × 25 columns

```python
# 将数据分成训练集和测试集
traning_set = data_cleaned.iloc[:999,:]
test_set = data_cleaned.iloc[999:,:]
```

```python
traning_set
```

      Close0
      H_L
      C_O
      volume
      Close1
      Close2
      Close3
      Close4
      Close5
      H_L1
      ...
      C_O2
      C_O3
      C_O4
      C_O5
      volume1
      volume2
      volume3
      volume4
      volume5
      label

      date

      2014-07-08
      7.687296
      17.42
      5.64
      7.705381
      7.685377
      7.686484
      7.687167
      7.682883
      7.679972
      15.12
      ...
      -1.75
      11.19
      6.87
      -4.64
      7.701070
      7.723054
      7.804076
      7.775869
      7.726915
      0.0

      2014-07-09
      7.672623
      30.25
      -29.43
      7.792546
      7.687296
      7.685377
      7.686484
      7.687167
      7.682883
      17.42
      ...
      -2.26
      -1.75
      11.19
      6.87
      7.705381
      7.701070
      7.723054
      7.804076
      7.775869
      0.0

      2014-07-10
      7.669892
      12.25
      -3.75
      7.746109
      7.672623
      7.687296
      7.685377
      7.686484
      7.687167
      30.25
      ...
      5.64
      -2.26
      -1.75
      11.19
      7.792546
      7.705381
      7.701070
      7.723054
      7.804076
      1.0

      2014-07-11
      7.672297
      19.95
      11.69
      7.787986
      7.669892
      7.672623
      7.687296
      7.685377
      7.686484
      12.25
      ...
      -29.43
      5.64
      -2.26
      -1.75
      7.746109
      7.792546
      7.705381
      7.701070
      7.723054
      1.0

      2014-07-14
      7.683293
      26.62
      22.22
      7.820588
      7.672297
      7.669892
      7.672623
      7.687296
      7.685377
      19.95
      ...
      -3.75
      -29.43
      5.64
      -2.26
      7.787986
      7.746109
      7.792546
      7.705381
      7.701070
      1.0

      ...
      ...
      ...
      ...
      ...
      ...
      ...
      ...
      ...
      ...
      ...
      ...
      ...
      ...
      ...
      ...
      ...
      ...
      ...
      ...
      ...
      ...

      2018-08-01
      8.145373
      96.83
      -82.64
      7.955922
      8.165551
      8.164818
      8.166566
      8.170822
      8.182489
      35.00
      ...
      -5.77
      -12.54
      -47.07
      -11.76
      7.832386
      7.914433
      7.846202
      7.955926
      7.985689
      0.0

      2018-08-02
      8.122953
      112.25
      -63.39
      8.005647
      8.145373
      8.165551
      8.164818
      8.166566
      8.170822
      96.83
      ...
      7.19
      -5.77
      -12.54
      -47.07
      7.955922
      7.832386
      7.914433
      7.846202
      7.955926
      0.0

      2018-08-03
      8.106297
      66.14
      -51.38
      7.850014
      8.122953
      8.145373
      8.165551
      8.164818
      8.166566
      112.25
      ...
      -82.64
      7.19
      -5.77
      -12.54
      8.005647
      7.955922
      7.832386
      7.914433
      7.846202
      0.0

      2018-08-06
      8.093545
      86.56
      -39.55
      7.891956
      8.106297
      8.122953
      8.145373
      8.165551
      8.164818
      66.14
      ...
      -63.39
      -82.64
      7.19
      -5.77
      7.850014
      8.005647
      7.955922
      7.832386
      7.914433
      1.0

      2018-08-07
      8.122333
      105.46
      83.89
      7.962767
      8.093545
      8.106297
      8.122953
      8.145373
      8.165551
      86.56
      ...
      -51.38
      -63.39
      -82.64
      7.19
      7.891956
      7.850014
      8.005647
      7.955922
      7.832386
      0.0

999 rows × 25 columns

```python
# 查看维度
traning_set.shape
```

    (999, 25)

## **Traning DNN Model**

```python
class DeepNeuralNetworkMdoel(nn.Module):
    # constructor of the class
    def __init__(self):
        super(DeepNeuralNetworkMdoel,self).__init__()
        # Fully connected Layer1
        self.FC_layer1 = nn.Linear(24,48)

        # Fully connected Layer2
        self.FC_layer2 = nn.Linear(48,36)

        # Fully connected Layer3
        self.FC_layer3 = nn.Linear(36,24)

        # Fully connected Layer4
        self.FC_layer4 = nn.Linear(24,12)

        # Fully connected Layer5
        self.FC_layer5 = nn.Linear(12,2)

    # Forward propagation function
    def forward(self,input_data):  # dim of input_data N * 24
        z1_= self.FC_layer1(input_data)
        z1 = torch.sigmoid(z1_)

        z2_= self.FC_layer2(z1)
        z2 = torch.sigmoid(z2_)

        z3_= self.FC_layer3(z2)
        z3 = torch.sigmoid(z3_)

        z4_= self.FC_layer4(z3)
        z4 = torch.sigmoid(z4_)

        z5_= self.FC_layer5(z4)   # 最后一层不加激活函数,后面调用entrypyloss函数

        return z5_
```

```python
x = traning_set.iloc[:,0:24]
y = traning_set.iloc[:,24]
x = np.array(x)
y = np.array(y)
x,y
```

    (array([[  7.68729573,  17.42      ,   5.64      , ...,   7.80407595,
               7.77586884,   7.72691539],
            [  7.67262294,  30.25      , -29.43      , ...,   7.72305408,
               7.80407595,   7.77586884],
            [  7.669892  ,  12.25      ,  -3.75      , ...,   7.70106981,
               7.72305408,   7.80407595],
            ...,
            [  8.10629736,  66.14      , -51.38      , ...,   7.83238638,
               7.91443305,   7.84620163],
            [  8.09354476,  86.56      , -39.55      , ...,   7.95592151,
               7.83238638,   7.91443305],
            [  8.12233266, 105.46      ,  83.89      , ...,   8.00564686,
               7.95592151,   7.83238638]]),
     array([0., 0., 1., 1., 1., 0., 0., 1., 1., 1., 1., 1., 1., 1., 1., 0., 1.,
            0., 1., 0., 0., 0., 1., 1., 0., 1., 0., 1., 1., 1., 0., 0., 1., 0.,
            0., 1., 0., 1., 1., 1., 1., 1., 1., 0., 0., 0., 1., 0., 0., 1., 1.,
            1., 0., 1., 1., 0., 1., 1., 1., 1., 1., 0., 0., 0., 1., 0., 0., 1.,
            0., 0., 0., 0., 0., 1., 1., 1., 1., 1., 1., 0., 1., 0., 1., 0., 1.,
            0., 1., 0., 0., 0., 0., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1.,
            1., 0., 1., 0., 1., 1., 1., 1., 0., 1., 1., 0., 0., 1., 1., 1., 1.,
            1., 1., 0., 1., 0., 0., 0., 1., 0., 1., 1., 0., 1., 1., 1., 1., 1.,
            0., 0., 0., 0., 0., 1., 0., 0., 0., 1., 1., 1., 1., 1., 1., 1., 0.,
            1., 1., 1., 0., 1., 0., 0., 1., 0., 1., 1., 1., 1., 1., 1., 0., 1.,
            1., 1., 0., 1., 1., 1., 0., 1., 1., 1., 1., 1., 0., 1., 1., 1., 0.,
            1., 1., 0., 1., 1., 1., 0., 1., 0., 1., 0., 1., 0., 0., 0., 1., 1.,
            1., 0., 0., 0., 0., 1., 1., 1., 1., 1., 1., 0., 0., 1., 1., 1., 0.,
            1., 1., 1., 0., 0., 0., 1., 0., 0., 1., 0., 0., 1., 1., 0., 0., 0.,
            1., 0., 0., 0., 1., 0., 0., 1., 1., 1., 0., 0., 1., 1., 1., 1., 0.,
            1., 0., 0., 0., 1., 0., 1., 1., 1., 0., 0., 1., 1., 0., 0., 1., 0.,
            1., 0., 1., 0., 0., 0., 0., 0., 1., 1., 1., 0., 1., 0., 1., 1., 0.,
            0., 0., 0., 1., 0., 1., 1., 1., 0., 1., 0., 1., 0., 1., 1., 1., 1.,
            0., 0., 1., 1., 1., 1., 0., 1., 1., 1., 1., 0., 1., 1., 0., 0., 1.,
            1., 1., 1., 0., 1., 0., 0., 1., 0., 0., 1., 0., 0., 1., 1., 0., 0.,
            1., 1., 1., 1., 0., 1., 0., 1., 0., 0., 1., 0., 0., 1., 1., 1., 1.,
            0., 0., 1., 0., 1., 1., 0., 0., 1., 1., 0., 1., 0., 1., 0., 1., 0.,
            1., 1., 0., 0., 1., 1., 0., 0., 0., 1., 0., 1., 0., 1., 0., 0., 1.,
            1., 0., 0., 1., 0., 1., 0., 1., 0., 1., 1., 1., 1., 1., 1., 0., 0.,
            1., 1., 1., 1., 1., 1., 1., 0., 1., 0., 1., 0., 0., 1., 1., 1., 1.,
            0., 0., 0., 1., 0., 1., 1., 0., 0., 1., 0., 0., 1., 0., 1., 0., 0.,
            0., 1., 0., 1., 0., 0., 1., 1., 1., 0., 1., 0., 0., 0., 1., 1., 0.,
            0., 1., 0., 1., 1., 0., 1., 1., 0., 0., 0., 0., 1., 1., 0., 1., 1.,
            0., 1., 0., 0., 1., 1., 1., 1., 1., 1., 1., 1., 0., 0., 1., 1., 1.,
            0., 0., 0., 0., 0., 1., 0., 1., 1., 0., 1., 0., 0., 1., 1., 1., 1.,
            1., 1., 0., 0., 1., 1., 0., 0., 0., 1., 0., 1., 0., 0., 0., 1., 1.,
            1., 0., 1., 1., 1., 0., 0., 0., 0., 0., 0., 1., 0., 1., 1., 0., 0.,
            1., 0., 1., 1., 1., 1., 0., 1., 1., 0., 1., 0., 1., 1., 1., 0., 0.,
            0., 0., 0., 1., 0., 1., 0., 1., 1., 0., 1., 1., 1., 0., 0., 1., 0.,
            1., 1., 1., 1., 1., 1., 1., 0., 1., 0., 0., 0., 1., 0., 1., 0., 0.,
            0., 0., 1., 0., 0., 1., 0., 0., 1., 0., 0., 0., 1., 1., 1., 0., 0.,
            1., 0., 0., 0., 1., 0., 1., 1., 0., 1., 1., 1., 1., 1., 0., 1., 0.,
            1., 1., 1., 1., 0., 0., 1., 0., 1., 1., 1., 0., 1., 0., 1., 1., 0.,
            0., 1., 1., 0., 0., 1., 1., 0., 1., 1., 0., 1., 1., 0., 1., 1., 0.,
            0., 0., 0., 1., 1., 1., 1., 0., 1., 0., 1., 0., 0., 0., 0., 1., 1.,
            0., 1., 1., 1., 0., 0., 0., 0., 0., 0., 0., 0., 1., 1., 1., 1., 0.,
            0., 1., 1., 1., 0., 1., 0., 1., 1., 0., 0., 1., 1., 1., 1., 0., 1.,
            0., 0., 0., 1., 0., 1., 1., 1., 1., 1., 0., 1., 0., 0., 0., 1., 1.,
            0., 0., 1., 0., 1., 1., 0., 1., 1., 1., 0., 1., 0., 0., 1., 1., 1.,
            1., 0., 0., 0., 1., 1., 0., 0., 0., 1., 1., 0., 1., 1., 1., 1., 1.,
            0., 1., 1., 0., 0., 0., 1., 1., 1., 0., 0., 0., 0., 1., 1., 0., 1.,
            1., 0., 1., 0., 0., 0., 1., 1., 1., 1., 1., 1., 1., 1., 1., 0., 0.,
            1., 0., 0., 1., 1., 1., 1., 1., 0., 0., 0., 1., 0., 1., 1., 0., 1.,
            1., 1., 0., 0., 1., 1., 1., 1., 1., 0., 1., 0., 1., 0., 0., 0., 1.,
            1., 0., 0., 1., 1., 0., 1., 0., 0., 1., 1., 0., 1., 0., 0., 1., 0.,
            1., 1., 1., 1., 1., 1., 1., 1., 1., 0., 1., 1., 1., 0., 1., 1., 1.,
            1., 1., 0., 1., 0., 0., 1., 0., 1., 1., 0., 0., 0., 0., 1., 1., 1.,
            1., 1., 1., 0., 0., 1., 0., 1., 1., 0., 1., 1., 1., 0., 0., 1., 0.,
            1., 1., 0., 0., 0., 0., 1., 0., 1., 1., 0., 0., 0., 0., 1., 1., 0.,
            0., 0., 0., 1., 1., 0., 1., 1., 0., 0., 1., 1., 1., 0., 1., 1., 0.,
            1., 0., 1., 1., 0., 0., 1., 1., 0., 0., 0., 0., 1., 0., 0., 1., 0.,
            1., 1., 0., 0., 0., 1., 1., 0., 0., 0., 0., 1., 0., 1., 0., 0., 0.,
            0., 1., 0., 1., 0., 0., 1., 1., 1., 0., 1., 1., 0., 0., 0., 0., 1.,
            1., 1., 0., 0., 0., 0., 1., 0., 0., 0., 0., 1., 0.]))

```python
x = Variable(torch.FloatTensor(x))  # x为浮点类型的数据，所以用FloatTensor
y = Variable(torch.LongTensor(y)) # y需要转为int型数据
x.shape,y.shape
```

    (torch.Size([999, 24]), torch.Size([999]))

```python
alpha = 1.0
DNN_Model = DeepNeuralNetworkMdoel()
optimizer = torch.optim.SGD(DNN_Model.parameters(),lr = alpha)
loss_function = nn.CrossEntropyLoss()

# 动态调整学习率
def adjust_learning_rate(optimizer,epoch):
    if epoch <=100:
        lr = alpha
    elif epoch > 100:
        lr = alpha / (1 + 0.002 * (epoch-100))
    elif epoch > 10000:
        lr = alpha / (1 + 0.001 * (epoch-100))
    elif epoch > 50000:
        lr = alpha / (1 + 0.0008 * (epoch-100))
    elif epoch > 100000:
        lr = alpha / (1 + 0.0005 * (epoch-100))
    for param_group in optimizer.param_groups:
        param_group['lr'] = lr

```

1.1千万次迭代
2.forward传入的是训练集
3.损失函数算的是输出的预测值与真实值之间的差异
4.将损失值传入loss_list
5.每次训练都得到一个w,b,然后每次将w,b改变一个很小的值，不断改变w,b，使得y与y_hat趋近

```python
Iter_times = 10000000
loss_list = []
for i in range(Iter_times):
    outputs = DNN_Model.forward(x)  # 前向传播
    loss = loss_function(outputs,y) # 计算loss
    loss.backward() # 反向传播
    optimizer.step() # 更新参数
    optimizer.zero_grad() # 梯度清零

    if (i+1) % 500 == 0:
        print(i+1,'iterations have been completed!')
        print('     --> Now loss = ',loss)
        print('===========================')

    adjust_learning_rate(optimizer,i)
    loss_list.append(loss)
    if loss < 0.01:
        print('traning has been totally completed')
        break
```

    500 iterations have been completed!
         --> Now loss =  tensor(0.6882, grad_fn=<NllLossBackward>)
    ===========================
    1000 iterations have been completed!
         --> Now loss =  tensor(0.6881, grad_fn=<NllLossBackward>)
    ===========================
    1500 iterations have been completed!
         --> Now loss =  tensor(0.6879, grad_fn=<NllLossBackward>)
    ===========================
    2000 iterations have been completed!
         --> Now loss =  tensor(0.6876, grad_fn=<NllLossBackward>)
    ===========================
    2500 iterations have been completed!
         --> Now loss =  tensor(0.6868, grad_fn=<NllLossBackward>)
    ===========================
    3000 iterations have been completed!
         --> Now loss =  tensor(0.6838, grad_fn=<NllLossBackward>)
    ===========================
    3500 iterations have been completed!
         --> Now loss =  tensor(0.6614, grad_fn=<NllLossBackward>)
    ===========================
    4000 iterations have been completed!
         --> Now loss =  tensor(0.5995, grad_fn=<NllLossBackward>)
    ===========================
    4500 iterations have been completed!
         --> Now loss =  tensor(0.5922, grad_fn=<NllLossBackward>)
    ===========================
    5000 iterations have been completed!
         --> Now loss =  tensor(0.3805, grad_fn=<NllLossBackward>)
    ===========================
    5500 iterations have been completed!
         --> Now loss =  tensor(0.5964, grad_fn=<NllLossBackward>)
    ===========================
    6000 iterations have been completed!
         --> Now loss =  tensor(0.2865, grad_fn=<NllLossBackward>)
    ===========================
    6500 iterations have been completed!
         --> Now loss =  tensor(0.2210, grad_fn=<NllLossBackward>)
    ===========================
    7000 iterations have been completed!
         --> Now loss =  tensor(0.1873, grad_fn=<NllLossBackward>)
    ===========================
    7500 iterations have been completed!
         --> Now loss =  tensor(0.2056, grad_fn=<NllLossBackward>)
    ===========================
    8000 iterations have been completed!
         --> Now loss =  tensor(0.1611, grad_fn=<NllLossBackward>)
    ===========================
    8500 iterations have been completed!
         --> Now loss =  tensor(0.1401, grad_fn=<NllLossBackward>)
    ===========================
    9000 iterations have been completed!
         --> Now loss =  tensor(0.1283, grad_fn=<NllLossBackward>)
    ===========================
    9500 iterations have been completed!
         --> Now loss =  tensor(0.1283, grad_fn=<NllLossBackward>)
    ===========================
    10000 iterations have been completed!
         --> Now loss =  tensor(0.1087, grad_fn=<NllLossBackward>)
    ===========================
    10500 iterations have been completed!
         --> Now loss =  tensor(0.1000, grad_fn=<NllLossBackward>)
    ===========================
    11000 iterations have been completed!
         --> Now loss =  tensor(0.0957, grad_fn=<NllLossBackward>)
    ===========================
    11500 iterations have been completed!
         --> Now loss =  tensor(0.4757, grad_fn=<NllLossBackward>)
    ===========================
    12000 iterations have been completed!
         --> Now loss =  tensor(0.0949, grad_fn=<NllLossBackward>)
    ===========================
    12500 iterations have been completed!
         --> Now loss =  tensor(0.0874, grad_fn=<NllLossBackward>)
    ===========================
    13000 iterations have been completed!
         --> Now loss =  tensor(0.0791, grad_fn=<NllLossBackward>)
    ===========================
    13500 iterations have been completed!
         --> Now loss =  tensor(0.0766, grad_fn=<NllLossBackward>)
    ===========================
    14000 iterations have been completed!
         --> Now loss =  tensor(0.0704, grad_fn=<NllLossBackward>)
    ===========================
    14500 iterations have been completed!
         --> Now loss =  tensor(0.0677, grad_fn=<NllLossBackward>)
    ===========================
    15000 iterations have been completed!
         --> Now loss =  tensor(0.0662, grad_fn=<NllLossBackward>)
    ===========================
    15500 iterations have been completed!
         --> Now loss =  tensor(0.0647, grad_fn=<NllLossBackward>)
    ===========================
    16000 iterations have been completed!
         --> Now loss =  tensor(0.0635, grad_fn=<NllLossBackward>)
    ===========================
    16500 iterations have been completed!
         --> Now loss =  tensor(0.0622, grad_fn=<NllLossBackward>)
    ===========================
    17000 iterations have been completed!
         --> Now loss =  tensor(0.0610, grad_fn=<NllLossBackward>)
    ===========================
    17500 iterations have been completed!
         --> Now loss =  tensor(0.0597, grad_fn=<NllLossBackward>)
    ===========================
    18000 iterations have been completed!
         --> Now loss =  tensor(0.0583, grad_fn=<NllLossBackward>)
    ===========================
    18500 iterations have been completed!
         --> Now loss =  tensor(0.0566, grad_fn=<NllLossBackward>)
    ===========================
    19000 iterations have been completed!
         --> Now loss =  tensor(0.0553, grad_fn=<NllLossBackward>)
    ===========================
    19500 iterations have been completed!
         --> Now loss =  tensor(0.0540, grad_fn=<NllLossBackward>)
    ===========================
    20000 iterations have been completed!
         --> Now loss =  tensor(0.0523, grad_fn=<NllLossBackward>)
    ===========================
    20500 iterations have been completed!
         --> Now loss =  tensor(0.0510, grad_fn=<NllLossBackward>)
    ===========================
    21000 iterations have been completed!
         --> Now loss =  tensor(0.0499, grad_fn=<NllLossBackward>)
    ===========================
    21500 iterations have been completed!
         --> Now loss =  tensor(0.0489, grad_fn=<NllLossBackward>)
    ===========================
    22000 iterations have been completed!
         --> Now loss =  tensor(0.0478, grad_fn=<NllLossBackward>)
    ===========================
    22500 iterations have been completed!
         --> Now loss =  tensor(0.0465, grad_fn=<NllLossBackward>)
    ===========================
    23000 iterations have been completed!
         --> Now loss =  tensor(0.0456, grad_fn=<NllLossBackward>)
    ===========================
    23500 iterations have been completed!
         --> Now loss =  tensor(0.0447, grad_fn=<NllLossBackward>)
    ===========================
    24000 iterations have been completed!
         --> Now loss =  tensor(0.0438, grad_fn=<NllLossBackward>)
    ===========================
    24500 iterations have been completed!
         --> Now loss =  tensor(0.0430, grad_fn=<NllLossBackward>)
    ===========================
    25000 iterations have been completed!
         --> Now loss =  tensor(0.0422, grad_fn=<NllLossBackward>)
    ===========================
    25500 iterations have been completed!
         --> Now loss =  tensor(0.0414, grad_fn=<NllLossBackward>)
    ===========================
    26000 iterations have been completed!
         --> Now loss =  tensor(0.0407, grad_fn=<NllLossBackward>)
    ===========================
    26500 iterations have been completed!
         --> Now loss =  tensor(0.0399, grad_fn=<NllLossBackward>)
    ===========================
    27000 iterations have been completed!
         --> Now loss =  tensor(0.0390, grad_fn=<NllLossBackward>)
    ===========================
    27500 iterations have been completed!
         --> Now loss =  tensor(0.0382, grad_fn=<NllLossBackward>)
    ===========================
    28000 iterations have been completed!
         --> Now loss =  tensor(0.0375, grad_fn=<NllLossBackward>)
    ===========================
    28500 iterations have been completed!
         --> Now loss =  tensor(0.0368, grad_fn=<NllLossBackward>)
    ===========================
    29000 iterations have been completed!
         --> Now loss =  tensor(0.0359, grad_fn=<NllLossBackward>)
    ===========================
    29500 iterations have been completed!
         --> Now loss =  tensor(0.0351, grad_fn=<NllLossBackward>)
    ===========================
    30000 iterations have been completed!
         --> Now loss =  tensor(0.0344, grad_fn=<NllLossBackward>)
    ===========================
    30500 iterations have been completed!
         --> Now loss =  tensor(0.0337, grad_fn=<NllLossBackward>)
    ===========================
    31000 iterations have been completed!
         --> Now loss =  tensor(0.0329, grad_fn=<NllLossBackward>)
    ===========================
    31500 iterations have been completed!
         --> Now loss =  tensor(0.0321, grad_fn=<NllLossBackward>)
    ===========================
    32000 iterations have been completed!
         --> Now loss =  tensor(0.0314, grad_fn=<NllLossBackward>)
    ===========================
    32500 iterations have been completed!
         --> Now loss =  tensor(0.0307, grad_fn=<NllLossBackward>)
    ===========================
    33000 iterations have been completed!
         --> Now loss =  tensor(0.0300, grad_fn=<NllLossBackward>)
    ===========================
    33500 iterations have been completed!
         --> Now loss =  tensor(0.0293, grad_fn=<NllLossBackward>)
    ===========================
    34000 iterations have been completed!
         --> Now loss =  tensor(0.0286, grad_fn=<NllLossBackward>)
    ===========================
    34500 iterations have been completed!
         --> Now loss =  tensor(0.0280, grad_fn=<NllLossBackward>)
    ===========================
    35000 iterations have been completed!
         --> Now loss =  tensor(0.0273, grad_fn=<NllLossBackward>)
    ===========================
    35500 iterations have been completed!
         --> Now loss =  tensor(0.0266, grad_fn=<NllLossBackward>)
    ===========================
    36000 iterations have been completed!
         --> Now loss =  tensor(0.0260, grad_fn=<NllLossBackward>)
    ===========================
    36500 iterations have been completed!
         --> Now loss =  tensor(0.0253, grad_fn=<NllLossBackward>)
    ===========================
    37000 iterations have been completed!
         --> Now loss =  tensor(0.0248, grad_fn=<NllLossBackward>)
    ===========================
    37500 iterations have been completed!
         --> Now loss =  tensor(0.0242, grad_fn=<NllLossBackward>)
    ===========================
    38000 iterations have been completed!
         --> Now loss =  tensor(0.0237, grad_fn=<NllLossBackward>)
    ===========================
    38500 iterations have been completed!
         --> Now loss =  tensor(0.0232, grad_fn=<NllLossBackward>)
    ===========================
    39000 iterations have been completed!
         --> Now loss =  tensor(0.0228, grad_fn=<NllLossBackward>)
    ===========================
    39500 iterations have been completed!
         --> Now loss =  tensor(0.0223, grad_fn=<NllLossBackward>)
    ===========================
    40000 iterations have been completed!
         --> Now loss =  tensor(0.0219, grad_fn=<NllLossBackward>)
    ===========================
    40500 iterations have been completed!
         --> Now loss =  tensor(0.0215, grad_fn=<NllLossBackward>)
    ===========================
    41000 iterations have been completed!
         --> Now loss =  tensor(0.0212, grad_fn=<NllLossBackward>)
    ===========================
    41500 iterations have been completed!
         --> Now loss =  tensor(0.0208, grad_fn=<NllLossBackward>)
    ===========================
    42000 iterations have been completed!
         --> Now loss =  tensor(0.0205, grad_fn=<NllLossBackward>)
    ===========================
    42500 iterations have been completed!
         --> Now loss =  tensor(0.0201, grad_fn=<NllLossBackward>)
    ===========================
    43000 iterations have been completed!
         --> Now loss =  tensor(0.0198, grad_fn=<NllLossBackward>)
    ===========================
    43500 iterations have been completed!
         --> Now loss =  tensor(0.0195, grad_fn=<NllLossBackward>)
    ===========================
    44000 iterations have been completed!
         --> Now loss =  tensor(0.0192, grad_fn=<NllLossBackward>)
    ===========================
    44500 iterations have been completed!
         --> Now loss =  tensor(0.0189, grad_fn=<NllLossBackward>)
    ===========================
    45000 iterations have been completed!
         --> Now loss =  tensor(0.0187, grad_fn=<NllLossBackward>)
    ===========================
    45500 iterations have been completed!
         --> Now loss =  tensor(0.0185, grad_fn=<NllLossBackward>)
    ===========================
    46000 iterations have been completed!
         --> Now loss =  tensor(0.0182, grad_fn=<NllLossBackward>)
    ===========================
    46500 iterations have been completed!
         --> Now loss =  tensor(0.0180, grad_fn=<NllLossBackward>)
    ===========================
    47000 iterations have been completed!
         --> Now loss =  tensor(0.0178, grad_fn=<NllLossBackward>)
    ===========================
    47500 iterations have been completed!
         --> Now loss =  tensor(0.0176, grad_fn=<NllLossBackward>)
    ===========================
    48000 iterations have been completed!
         --> Now loss =  tensor(0.0175, grad_fn=<NllLossBackward>)
    ===========================
    48500 iterations have been completed!
         --> Now loss =  tensor(0.0173, grad_fn=<NllLossBackward>)
    ===========================
    49000 iterations have been completed!
         --> Now loss =  tensor(0.0171, grad_fn=<NllLossBackward>)
    ===========================
    49500 iterations have been completed!
         --> Now loss =  tensor(0.0170, grad_fn=<NllLossBackward>)
    ===========================
    50000 iterations have been completed!
         --> Now loss =  tensor(0.0168, grad_fn=<NllLossBackward>)
    ===========================
    50500 iterations have been completed!
         --> Now loss =  tensor(0.0167, grad_fn=<NllLossBackward>)
    ===========================
    51000 iterations have been completed!
         --> Now loss =  tensor(0.0165, grad_fn=<NllLossBackward>)
    ===========================
    51500 iterations have been completed!
         --> Now loss =  tensor(0.0164, grad_fn=<NllLossBackward>)
    ===========================
    52000 iterations have been completed!
         --> Now loss =  tensor(0.0163, grad_fn=<NllLossBackward>)
    ===========================
    52500 iterations have been completed!
         --> Now loss =  tensor(0.0162, grad_fn=<NllLossBackward>)
    ===========================
    53000 iterations have been completed!
         --> Now loss =  tensor(0.0161, grad_fn=<NllLossBackward>)
    ===========================
    53500 iterations have been completed!
         --> Now loss =  tensor(0.0160, grad_fn=<NllLossBackward>)
    ===========================
    54000 iterations have been completed!
         --> Now loss =  tensor(0.0159, grad_fn=<NllLossBackward>)
    ===========================
    54500 iterations have been completed!
         --> Now loss =  tensor(0.0158, grad_fn=<NllLossBackward>)
    ===========================
    55000 iterations have been completed!
         --> Now loss =  tensor(0.0157, grad_fn=<NllLossBackward>)
    ===========================
    55500 iterations have been completed!
         --> Now loss =  tensor(0.0156, grad_fn=<NllLossBackward>)
    ===========================
    56000 iterations have been completed!
         --> Now loss =  tensor(0.0155, grad_fn=<NllLossBackward>)
    ===========================
    56500 iterations have been completed!
         --> Now loss =  tensor(0.0154, grad_fn=<NllLossBackward>)
    ===========================
    57000 iterations have been completed!
         --> Now loss =  tensor(0.0154, grad_fn=<NllLossBackward>)
    ===========================
    57500 iterations have been completed!
         --> Now loss =  tensor(0.0153, grad_fn=<NllLossBackward>)
    ===========================
    58000 iterations have been completed!
         --> Now loss =  tensor(0.0152, grad_fn=<NllLossBackward>)
    ===========================
    58500 iterations have been completed!
         --> Now loss =  tensor(0.0151, grad_fn=<NllLossBackward>)
    ===========================
    59000 iterations have been completed!
         --> Now loss =  tensor(0.0151, grad_fn=<NllLossBackward>)
    ===========================
    59500 iterations have been completed!
         --> Now loss =  tensor(0.0150, grad_fn=<NllLossBackward>)
    ===========================
    60000 iterations have been completed!
         --> Now loss =  tensor(0.0149, grad_fn=<NllLossBackward>)
    ===========================
    60500 iterations have been completed!
         --> Now loss =  tensor(0.0149, grad_fn=<NllLossBackward>)
    ===========================
    61000 iterations have been completed!
         --> Now loss =  tensor(0.0148, grad_fn=<NllLossBackward>)
    ===========================
    61500 iterations have been completed!
         --> Now loss =  tensor(0.0148, grad_fn=<NllLossBackward>)
    ===========================
    62000 iterations have been completed!
         --> Now loss =  tensor(0.0147, grad_fn=<NllLossBackward>)
    ===========================
    62500 iterations have been completed!
         --> Now loss =  tensor(0.0146, grad_fn=<NllLossBackward>)
    ===========================
    63000 iterations have been completed!
         --> Now loss =  tensor(0.0146, grad_fn=<NllLossBackward>)
    ===========================
    63500 iterations have been completed!
         --> Now loss =  tensor(0.0145, grad_fn=<NllLossBackward>)
    ===========================
    64000 iterations have been completed!
         --> Now loss =  tensor(0.0145, grad_fn=<NllLossBackward>)
    ===========================
    64500 iterations have been completed!
         --> Now loss =  tensor(0.0144, grad_fn=<NllLossBackward>)
    ===========================
    65000 iterations have been completed!
         --> Now loss =  tensor(0.0144, grad_fn=<NllLossBackward>)
    ===========================
    65500 iterations have been completed!
         --> Now loss =  tensor(0.0143, grad_fn=<NllLossBackward>)
    ===========================
    66000 iterations have been completed!
         --> Now loss =  tensor(0.0143, grad_fn=<NllLossBackward>)
    ===========================
    66500 iterations have been completed!
         --> Now loss =  tensor(0.0142, grad_fn=<NllLossBackward>)
    ===========================
    67000 iterations have been completed!
         --> Now loss =  tensor(0.0142, grad_fn=<NllLossBackward>)
    ===========================
    67500 iterations have been completed!
         --> Now loss =  tensor(0.0142, grad_fn=<NllLossBackward>)
    ===========================
    68000 iterations have been completed!
         --> Now loss =  tensor(0.0141, grad_fn=<NllLossBackward>)
    ===========================
    68500 iterations have been completed!
         --> Now loss =  tensor(0.0141, grad_fn=<NllLossBackward>)
    ===========================
    69000 iterations have been completed!
         --> Now loss =  tensor(0.0140, grad_fn=<NllLossBackward>)
    ===========================
    69500 iterations have been completed!
         --> Now loss =  tensor(0.0140, grad_fn=<NllLossBackward>)
    ===========================
    70000 iterations have been completed!
         --> Now loss =  tensor(0.0140, grad_fn=<NllLossBackward>)
    ===========================
    70500 iterations have been completed!
         --> Now loss =  tensor(0.0139, grad_fn=<NllLossBackward>)
    ===========================
    71000 iterations have been completed!
         --> Now loss =  tensor(0.0139, grad_fn=<NllLossBackward>)
    ===========================
    71500 iterations have been completed!
         --> Now loss =  tensor(0.0138, grad_fn=<NllLossBackward>)
    ===========================
    72000 iterations have been completed!
         --> Now loss =  tensor(0.0138, grad_fn=<NllLossBackward>)
    ===========================
    72500 iterations have been completed!
         --> Now loss =  tensor(0.0138, grad_fn=<NllLossBackward>)
    ===========================
    73000 iterations have been completed!
         --> Now loss =  tensor(0.0137, grad_fn=<NllLossBackward>)
    ===========================
    73500 iterations have been completed!
         --> Now loss =  tensor(0.0137, grad_fn=<NllLossBackward>)
    ===========================
    74000 iterations have been completed!
         --> Now loss =  tensor(0.0137, grad_fn=<NllLossBackward>)
    ===========================
    74500 iterations have been completed!
         --> Now loss =  tensor(0.0136, grad_fn=<NllLossBackward>)
    ===========================
    75000 iterations have been completed!
         --> Now loss =  tensor(0.0136, grad_fn=<NllLossBackward>)
    ===========================
    75500 iterations have been completed!
         --> Now loss =  tensor(0.0136, grad_fn=<NllLossBackward>)
    ===========================
    76000 iterations have been completed!
         --> Now loss =  tensor(0.0135, grad_fn=<NllLossBackward>)
    ===========================
    76500 iterations have been completed!
         --> Now loss =  tensor(0.0135, grad_fn=<NllLossBackward>)
    ===========================
    77000 iterations have been completed!
         --> Now loss =  tensor(0.0135, grad_fn=<NllLossBackward>)
    ===========================
    77500 iterations have been completed!
         --> Now loss =  tensor(0.0135, grad_fn=<NllLossBackward>)
    ===========================
    78000 iterations have been completed!
         --> Now loss =  tensor(0.0134, grad_fn=<NllLossBackward>)
    ===========================
    78500 iterations have been completed!
         --> Now loss =  tensor(0.0134, grad_fn=<NllLossBackward>)
    ===========================
    79000 iterations have been completed!
         --> Now loss =  tensor(0.0134, grad_fn=<NllLossBackward>)
    ===========================
    79500 iterations have been completed!
         --> Now loss =  tensor(0.0133, grad_fn=<NllLossBackward>)
    ===========================
    80000 iterations have been completed!
         --> Now loss =  tensor(0.0133, grad_fn=<NllLossBackward>)
    ===========================
    80500 iterations have been completed!
         --> Now loss =  tensor(0.0133, grad_fn=<NllLossBackward>)
    ===========================
    81000 iterations have been completed!
         --> Now loss =  tensor(0.0133, grad_fn=<NllLossBackward>)
    ===========================
    81500 iterations have been completed!
         --> Now loss =  tensor(0.0132, grad_fn=<NllLossBackward>)
    ===========================
    82000 iterations have been completed!
         --> Now loss =  tensor(0.0132, grad_fn=<NllLossBackward>)
    ===========================
    82500 iterations have been completed!
         --> Now loss =  tensor(0.0132, grad_fn=<NllLossBackward>)
    ===========================
    83000 iterations have been completed!
         --> Now loss =  tensor(0.0132, grad_fn=<NllLossBackward>)
    ===========================
    83500 iterations have been completed!
         --> Now loss =  tensor(0.0131, grad_fn=<NllLossBackward>)
    ===========================
    84000 iterations have been completed!
         --> Now loss =  tensor(0.0131, grad_fn=<NllLossBackward>)
    ===========================
    84500 iterations have been completed!
         --> Now loss =  tensor(0.0131, grad_fn=<NllLossBackward>)
    ===========================
    85000 iterations have been completed!
         --> Now loss =  tensor(0.0131, grad_fn=<NllLossBackward>)
    ===========================
    85500 iterations have been completed!
         --> Now loss =  tensor(0.0131, grad_fn=<NllLossBackward>)
    ===========================
    86000 iterations have been completed!
         --> Now loss =  tensor(0.0130, grad_fn=<NllLossBackward>)
    ===========================
    86500 iterations have been completed!
         --> Now loss =  tensor(0.0130, grad_fn=<NllLossBackward>)
    ===========================
    87000 iterations have been completed!
         --> Now loss =  tensor(0.0130, grad_fn=<NllLossBackward>)
    ===========================
    87500 iterations have been completed!
         --> Now loss =  tensor(0.0130, grad_fn=<NllLossBackward>)
    ===========================
    88000 iterations have been completed!
         --> Now loss =  tensor(0.0130, grad_fn=<NllLossBackward>)
    ===========================
    88500 iterations have been completed!
         --> Now loss =  tensor(0.0129, grad_fn=<NllLossBackward>)
    ===========================
    89000 iterations have been completed!
         --> Now loss =  tensor(0.0129, grad_fn=<NllLossBackward>)
    ===========================
    89500 iterations have been completed!
         --> Now loss =  tensor(0.0129, grad_fn=<NllLossBackward>)
    ===========================
    90000 iterations have been completed!
         --> Now loss =  tensor(0.0129, grad_fn=<NllLossBackward>)
    ===========================
    90500 iterations have been completed!
         --> Now loss =  tensor(0.0129, grad_fn=<NllLossBackward>)
    ===========================
    91000 iterations have been completed!
         --> Now loss =  tensor(0.0128, grad_fn=<NllLossBackward>)
    ===========================
    91500 iterations have been completed!
         --> Now loss =  tensor(0.0128, grad_fn=<NllLossBackward>)
    ===========================
    92000 iterations have been completed!
         --> Now loss =  tensor(0.0128, grad_fn=<NllLossBackward>)
    ===========================
    92500 iterations have been completed!
         --> Now loss =  tensor(0.0128, grad_fn=<NllLossBackward>)
    ===========================
    93000 iterations have been completed!
         --> Now loss =  tensor(0.0128, grad_fn=<NllLossBackward>)
    ===========================
    93500 iterations have been completed!
         --> Now loss =  tensor(0.0127, grad_fn=<NllLossBackward>)
    ===========================
    94000 iterations have been completed!
         --> Now loss =  tensor(0.0127, grad_fn=<NllLossBackward>)
    ===========================
    94500 iterations have been completed!
         --> Now loss =  tensor(0.0127, grad_fn=<NllLossBackward>)
    ===========================
    95000 iterations have been completed!
         --> Now loss =  tensor(0.0127, grad_fn=<NllLossBackward>)
    ===========================
    95500 iterations have been completed!
         --> Now loss =  tensor(0.0127, grad_fn=<NllLossBackward>)
    ===========================
    96000 iterations have been completed!
         --> Now loss =  tensor(0.0127, grad_fn=<NllLossBackward>)
    ===========================
    96500 iterations have been completed!
         --> Now loss =  tensor(0.0126, grad_fn=<NllLossBackward>)
    ===========================
    97000 iterations have been completed!
         --> Now loss =  tensor(0.0126, grad_fn=<NllLossBackward>)
    ===========================
    97500 iterations have been completed!
         --> Now loss =  tensor(0.0126, grad_fn=<NllLossBackward>)
    ===========================
    98000 iterations have been completed!
         --> Now loss =  tensor(0.0126, grad_fn=<NllLossBackward>)
    ===========================
    98500 iterations have been completed!
         --> Now loss =  tensor(0.0126, grad_fn=<NllLossBackward>)
    ===========================
    99000 iterations have been completed!
         --> Now loss =  tensor(0.0126, grad_fn=<NllLossBackward>)
    ===========================
    99500 iterations have been completed!
         --> Now loss =  tensor(0.0126, grad_fn=<NllLossBackward>)
    ===========================
    100000 iterations have been completed!
         --> Now loss =  tensor(0.0125, grad_fn=<NllLossBackward>)
    ===========================
    100500 iterations have been completed!
         --> Now loss =  tensor(0.0125, grad_fn=<NllLossBackward>)
    ===========================
    101000 iterations have been completed!
         --> Now loss =  tensor(0.0125, grad_fn=<NllLossBackward>)
    ===========================
    101500 iterations have been completed!
         --> Now loss =  tensor(0.0125, grad_fn=<NllLossBackward>)
    ===========================
    102000 iterations have been completed!
         --> Now loss =  tensor(0.0125, grad_fn=<NllLossBackward>)
    ===========================
    102500 iterations have been completed!
         --> Now loss =  tensor(0.0125, grad_fn=<NllLossBackward>)
    ===========================
    103000 iterations have been completed!
         --> Now loss =  tensor(0.0125, grad_fn=<NllLossBackward>)
    ===========================
    103500 iterations have been completed!
         --> Now loss =  tensor(0.0124, grad_fn=<NllLossBackward>)
    ===========================
    104000 iterations have been completed!
         --> Now loss =  tensor(0.0124, grad_fn=<NllLossBackward>)
    ===========================
    104500 iterations have been completed!
         --> Now loss =  tensor(0.0124, grad_fn=<NllLossBackward>)
    ===========================
    105000 iterations have been completed!
         --> Now loss =  tensor(0.0124, grad_fn=<NllLossBackward>)
    ===========================
    105500 iterations have been completed!
         --> Now loss =  tensor(0.0124, grad_fn=<NllLossBackward>)
    ===========================
    106000 iterations have been completed!
         --> Now loss =  tensor(0.0124, grad_fn=<NllLossBackward>)
    ===========================
    106500 iterations have been completed!
         --> Now loss =  tensor(0.0124, grad_fn=<NllLossBackward>)
    ===========================
    107000 iterations have been completed!
         --> Now loss =  tensor(0.0123, grad_fn=<NllLossBackward>)
    ===========================
    107500 iterations have been completed!
         --> Now loss =  tensor(0.0123, grad_fn=<NllLossBackward>)
    ===========================
    108000 iterations have been completed!
         --> Now loss =  tensor(0.0123, grad_fn=<NllLossBackward>)
    ===========================
    108500 iterations have been completed!
         --> Now loss =  tensor(0.0123, grad_fn=<NllLossBackward>)
    ===========================
    109000 iterations have been completed!
         --> Now loss =  tensor(0.0123, grad_fn=<NllLossBackward>)
    ===========================
    109500 iterations have been completed!
         --> Now loss =  tensor(0.0123, grad_fn=<NllLossBackward>)
    ===========================
    110000 iterations have been completed!
         --> Now loss =  tensor(0.0123, grad_fn=<NllLossBackward>)
    ===========================
    110500 iterations have been completed!
         --> Now loss =  tensor(0.0123, grad_fn=<NllLossBackward>)
    ===========================
    111000 iterations have been completed!
         --> Now loss =  tensor(0.0122, grad_fn=<NllLossBackward>)
    ===========================
    111500 iterations have been completed!
         --> Now loss =  tensor(0.0122, grad_fn=<NllLossBackward>)
    ===========================
    112000 iterations have been completed!
         --> Now loss =  tensor(0.0122, grad_fn=<NllLossBackward>)
    ===========================
    112500 iterations have been completed!
         --> Now loss =  tensor(0.0122, grad_fn=<NllLossBackward>)
    ===========================
    113000 iterations have been completed!
         --> Now loss =  tensor(0.0122, grad_fn=<NllLossBackward>)
    ===========================
    113500 iterations have been completed!
         --> Now loss =  tensor(0.0122, grad_fn=<NllLossBackward>)
    ===========================
    114000 iterations have been completed!
         --> Now loss =  tensor(0.0122, grad_fn=<NllLossBackward>)
    ===========================
    114500 iterations have been completed!
         --> Now loss =  tensor(0.0121, grad_fn=<NllLossBackward>)
    ===========================
    115000 iterations have been completed!
         --> Now loss =  tensor(0.0121, grad_fn=<NllLossBackward>)
    ===========================
    115500 iterations have been completed!
         --> Now loss =  tensor(0.0121, grad_fn=<NllLossBackward>)
    ===========================
    116000 iterations have been completed!
         --> Now loss =  tensor(0.0121, grad_fn=<NllLossBackward>)
    ===========================
    116500 iterations have been completed!
         --> Now loss =  tensor(0.0120, grad_fn=<NllLossBackward>)
    ===========================
    117000 iterations have been completed!
         --> Now loss =  tensor(0.0119, grad_fn=<NllLossBackward>)
    ===========================
    117500 iterations have been completed!
         --> Now loss =  tensor(0.0119, grad_fn=<NllLossBackward>)
    ===========================
    118000 iterations have been completed!
         --> Now loss =  tensor(0.0118, grad_fn=<NllLossBackward>)
    ===========================
    118500 iterations have been completed!
         --> Now loss =  tensor(0.0118, grad_fn=<NllLossBackward>)
    ===========================
    119000 iterations have been completed!
         --> Now loss =  tensor(0.0117, grad_fn=<NllLossBackward>)
    ===========================
    119500 iterations have been completed!
         --> Now loss =  tensor(0.0116, grad_fn=<NllLossBackward>)
    ===========================
    120000 iterations have been completed!
         --> Now loss =  tensor(0.0116, grad_fn=<NllLossBackward>)
    ===========================
    120500 iterations have been completed!
         --> Now loss =  tensor(0.0115, grad_fn=<NllLossBackward>)
    ===========================
    121000 iterations have been completed!
         --> Now loss =  tensor(0.0115, grad_fn=<NllLossBackward>)
    ===========================
    121500 iterations have been completed!
         --> Now loss =  tensor(0.0115, grad_fn=<NllLossBackward>)
    ===========================
    122000 iterations have been completed!
         --> Now loss =  tensor(0.0114, grad_fn=<NllLossBackward>)
    ===========================
    122500 iterations have been completed!
         --> Now loss =  tensor(0.0114, grad_fn=<NllLossBackward>)
    ===========================
    123000 iterations have been completed!
         --> Now loss =  tensor(0.0113, grad_fn=<NllLossBackward>)
    ===========================
    123500 iterations have been completed!
         --> Now loss =  tensor(0.0113, grad_fn=<NllLossBackward>)
    ===========================
    124000 iterations have been completed!
         --> Now loss =  tensor(0.0113, grad_fn=<NllLossBackward>)
    ===========================
    124500 iterations have been completed!
         --> Now loss =  tensor(0.0112, grad_fn=<NllLossBackward>)
    ===========================
    125000 iterations have been completed!
         --> Now loss =  tensor(0.0112, grad_fn=<NllLossBackward>)
    ===========================
    125500 iterations have been completed!
         --> Now loss =  tensor(0.0112, grad_fn=<NllLossBackward>)
    ===========================
    126000 iterations have been completed!
         --> Now loss =  tensor(0.0111, grad_fn=<NllLossBackward>)
    ===========================
    126500 iterations have been completed!
         --> Now loss =  tensor(0.0111, grad_fn=<NllLossBackward>)
    ===========================
    127000 iterations have been completed!
         --> Now loss =  tensor(0.0111, grad_fn=<NllLossBackward>)
    ===========================
    127500 iterations have been completed!
         --> Now loss =  tensor(0.0110, grad_fn=<NllLossBackward>)
    ===========================
    128000 iterations have been completed!
         --> Now loss =  tensor(0.0110, grad_fn=<NllLossBackward>)
    ===========================
    128500 iterations have been completed!
         --> Now loss =  tensor(0.0110, grad_fn=<NllLossBackward>)
    ===========================
    129000 iterations have been completed!
         --> Now loss =  tensor(0.0109, grad_fn=<NllLossBackward>)
    ===========================
    129500 iterations have been completed!
         --> Now loss =  tensor(0.0109, grad_fn=<NllLossBackward>)
    ===========================
    130000 iterations have been completed!
         --> Now loss =  tensor(0.0109, grad_fn=<NllLossBackward>)
    ===========================
    130500 iterations have been completed!
         --> Now loss =  tensor(0.0109, grad_fn=<NllLossBackward>)
    ===========================
    131000 iterations have been completed!
         --> Now loss =  tensor(0.0108, grad_fn=<NllLossBackward>)
    ===========================
    131500 iterations have been completed!
         --> Now loss =  tensor(0.0108, grad_fn=<NllLossBackward>)
    ===========================
    132000 iterations have been completed!
         --> Now loss =  tensor(0.0108, grad_fn=<NllLossBackward>)
    ===========================
    132500 iterations have been completed!
         --> Now loss =  tensor(0.0108, grad_fn=<NllLossBackward>)
    ===========================
    133000 iterations have been completed!
         --> Now loss =  tensor(0.0108, grad_fn=<NllLossBackward>)
    ===========================
    133500 iterations have been completed!
         --> Now loss =  tensor(0.0108, grad_fn=<NllLossBackward>)
    ===========================
    134000 iterations have been completed!
         --> Now loss =  tensor(0.0107, grad_fn=<NllLossBackward>)
    ===========================
    134500 iterations have been completed!
         --> Now loss =  tensor(0.0107, grad_fn=<NllLossBackward>)
    ===========================
    135000 iterations have been completed!
         --> Now loss =  tensor(0.0107, grad_fn=<NllLossBackward>)
    ===========================
    135500 iterations have been completed!
         --> Now loss =  tensor(0.0107, grad_fn=<NllLossBackward>)
    ===========================
    136000 iterations have been completed!
         --> Now loss =  tensor(0.0107, grad_fn=<NllLossBackward>)
    ===========================
    136500 iterations have been completed!
         --> Now loss =  tensor(0.0107, grad_fn=<NllLossBackward>)
    ===========================
    137000 iterations have been completed!
         --> Now loss =  tensor(0.0106, grad_fn=<NllLossBackward>)
    ===========================
    137500 iterations have been completed!
         --> Now loss =  tensor(0.0106, grad_fn=<NllLossBackward>)
    ===========================
    138000 iterations have been completed!
         --> Now loss =  tensor(0.0106, grad_fn=<NllLossBackward>)
    ===========================
    138500 iterations have been completed!
         --> Now loss =  tensor(0.0106, grad_fn=<NllLossBackward>)
    ===========================
    139000 iterations have been completed!
         --> Now loss =  tensor(0.0106, grad_fn=<NllLossBackward>)
    ===========================
    139500 iterations have been completed!
         --> Now loss =  tensor(0.0106, grad_fn=<NllLossBackward>)
    ===========================
    140000 iterations have been completed!
         --> Now loss =  tensor(0.0106, grad_fn=<NllLossBackward>)
    ===========================
    140500 iterations have been completed!
         --> Now loss =  tensor(0.0106, grad_fn=<NllLossBackward>)
    ===========================
    141000 iterations have been completed!
         --> Now loss =  tensor(0.0105, grad_fn=<NllLossBackward>)
    ===========================
    141500 iterations have been completed!
         --> Now loss =  tensor(0.0105, grad_fn=<NllLossBackward>)
    ===========================
    142000 iterations have been completed!
         --> Now loss =  tensor(0.0105, grad_fn=<NllLossBackward>)
    ===========================
    142500 iterations have been completed!
         --> Now loss =  tensor(0.0105, grad_fn=<NllLossBackward>)
    ===========================
    143000 iterations have been completed!
         --> Now loss =  tensor(0.0105, grad_fn=<NllLossBackward>)
    ===========================
    143500 iterations have been completed!
         --> Now loss =  tensor(0.0105, grad_fn=<NllLossBackward>)
    ===========================
    144000 iterations have been completed!
         --> Now loss =  tensor(0.0105, grad_fn=<NllLossBackward>)
    ===========================
    144500 iterations have been completed!
         --> Now loss =  tensor(0.0105, grad_fn=<NllLossBackward>)
    ===========================
    145000 iterations have been completed!
         --> Now loss =  tensor(0.0105, grad_fn=<NllLossBackward>)
    ===========================
    145500 iterations have been completed!
         --> Now loss =  tensor(0.0105, grad_fn=<NllLossBackward>)
    ===========================
    146000 iterations have been completed!
         --> Now loss =  tensor(0.0105, grad_fn=<NllLossBackward>)
    ===========================
    146500 iterations have been completed!
         --> Now loss =  tensor(0.0104, grad_fn=<NllLossBackward>)
    ===========================
    147000 iterations have been completed!
         --> Now loss =  tensor(0.0104, grad_fn=<NllLossBackward>)
    ===========================
    147500 iterations have been completed!
         --> Now loss =  tensor(0.0104, grad_fn=<NllLossBackward>)
    ===========================
    148000 iterations have been completed!
         --> Now loss =  tensor(0.0104, grad_fn=<NllLossBackward>)
    ===========================
    148500 iterations have been completed!
         --> Now loss =  tensor(0.0104, grad_fn=<NllLossBackward>)
    ===========================
    149000 iterations have been completed!
         --> Now loss =  tensor(0.0104, grad_fn=<NllLossBackward>)
    ===========================
    149500 iterations have been completed!
         --> Now loss =  tensor(0.0104, grad_fn=<NllLossBackward>)
    ===========================
    150000 iterations have been completed!
         --> Now loss =  tensor(0.0104, grad_fn=<NllLossBackward>)
    ===========================
    150500 iterations have been completed!
         --> Now loss =  tensor(0.0104, grad_fn=<NllLossBackward>)
    ===========================
    151000 iterations have been completed!
         --> Now loss =  tensor(0.0104, grad_fn=<NllLossBackward>)
    ===========================
    151500 iterations have been completed!
         --> Now loss =  tensor(0.0104, grad_fn=<NllLossBackward>)
    ===========================
    152000 iterations have been completed!
         --> Now loss =  tensor(0.0104, grad_fn=<NllLossBackward>)
    ===========================
    152500 iterations have been completed!
         --> Now loss =  tensor(0.0104, grad_fn=<NllLossBackward>)
    ===========================
    153000 iterations have been completed!
         --> Now loss =  tensor(0.0103, grad_fn=<NllLossBackward>)
    ===========================
    153500 iterations have been completed!
         --> Now loss =  tensor(0.0103, grad_fn=<NllLossBackward>)
    ===========================
    154000 iterations have been completed!
         --> Now loss =  tensor(0.0103, grad_fn=<NllLossBackward>)
    ===========================
    154500 iterations have been completed!
         --> Now loss =  tensor(0.0103, grad_fn=<NllLossBackward>)
    ===========================
    155000 iterations have been completed!
         --> Now loss =  tensor(0.0103, grad_fn=<NllLossBackward>)
    ===========================
    155500 iterations have been completed!
         --> Now loss =  tensor(0.0103, grad_fn=<NllLossBackward>)
    ===========================
    156000 iterations have been completed!
         --> Now loss =  tensor(0.0103, grad_fn=<NllLossBackward>)
    ===========================
    156500 iterations have been completed!
         --> Now loss =  tensor(0.0103, grad_fn=<NllLossBackward>)
    ===========================
    157000 iterations have been completed!
         --> Now loss =  tensor(0.0103, grad_fn=<NllLossBackward>)
    ===========================
    157500 iterations have been completed!
         --> Now loss =  tensor(0.0103, grad_fn=<NllLossBackward>)
    ===========================
    158000 iterations have been completed!
         --> Now loss =  tensor(0.0103, grad_fn=<NllLossBackward>)
    ===========================
    158500 iterations have been completed!
         --> Now loss =  tensor(0.0103, grad_fn=<NllLossBackward>)
    ===========================
    159000 iterations have been completed!
         --> Now loss =  tensor(0.0103, grad_fn=<NllLossBackward>)
    ===========================
    159500 iterations have been completed!
         --> Now loss =  tensor(0.0103, grad_fn=<NllLossBackward>)
    ===========================
    160000 iterations have been completed!
         --> Now loss =  tensor(0.0102, grad_fn=<NllLossBackward>)
    ===========================
    160500 iterations have been completed!
         --> Now loss =  tensor(0.0102, grad_fn=<NllLossBackward>)
    ===========================
    161000 iterations have been completed!
         --> Now loss =  tensor(0.0102, grad_fn=<NllLossBackward>)
    ===========================
    161500 iterations have been completed!
         --> Now loss =  tensor(0.0102, grad_fn=<NllLossBackward>)
    ===========================
    162000 iterations have been completed!
         --> Now loss =  tensor(0.0102, grad_fn=<NllLossBackward>)
    ===========================
    162500 iterations have been completed!
         --> Now loss =  tensor(0.0102, grad_fn=<NllLossBackward>)
    ===========================
    163000 iterations have been completed!
         --> Now loss =  tensor(0.0102, grad_fn=<NllLossBackward>)
    ===========================
    163500 iterations have been completed!
         --> Now loss =  tensor(0.0102, grad_fn=<NllLossBackward>)
    ===========================
    164000 iterations have been completed!
         --> Now loss =  tensor(0.0102, grad_fn=<NllLossBackward>)
    ===========================
    164500 iterations have been completed!
         --> Now loss =  tensor(0.0102, grad_fn=<NllLossBackward>)
    ===========================
    165000 iterations have been completed!
         --> Now loss =  tensor(0.0102, grad_fn=<NllLossBackward>)
    ===========================
    165500 iterations have been completed!
         --> Now loss =  tensor(0.0102, grad_fn=<NllLossBackward>)
    ===========================
    166000 iterations have been completed!
         --> Now loss =  tensor(0.0102, grad_fn=<NllLossBackward>)
    ===========================
    166500 iterations have been completed!
         --> Now loss =  tensor(0.0102, grad_fn=<NllLossBackward>)
    ===========================
    167000 iterations have been completed!
         --> Now loss =  tensor(0.0102, grad_fn=<NllLossBackward>)
    ===========================
    167500 iterations have been completed!
         --> Now loss =  tensor(0.0102, grad_fn=<NllLossBackward>)
    ===========================
    168000 iterations have been completed!
         --> Now loss =  tensor(0.0102, grad_fn=<NllLossBackward>)
    ===========================
    168500 iterations have been completed!
         --> Now loss =  tensor(0.0101, grad_fn=<NllLossBackward>)
    ===========================
    169000 iterations have been completed!
         --> Now loss =  tensor(0.0101, grad_fn=<NllLossBackward>)
    ===========================
    169500 iterations have been completed!
         --> Now loss =  tensor(0.0101, grad_fn=<NllLossBackward>)
    ===========================
    170000 iterations have been completed!
         --> Now loss =  tensor(0.0101, grad_fn=<NllLossBackward>)
    ===========================
    170500 iterations have been completed!
         --> Now loss =  tensor(0.0101, grad_fn=<NllLossBackward>)
    ===========================
    171000 iterations have been completed!
         --> Now loss =  tensor(0.0101, grad_fn=<NllLossBackward>)
    ===========================
    171500 iterations have been completed!
         --> Now loss =  tensor(0.0101, grad_fn=<NllLossBackward>)
    ===========================
    172000 iterations have been completed!
         --> Now loss =  tensor(0.0101, grad_fn=<NllLossBackward>)
    ===========================
    172500 iterations have been completed!
         --> Now loss =  tensor(0.0101, grad_fn=<NllLossBackward>)
    ===========================
    173000 iterations have been completed!
         --> Now loss =  tensor(0.0101, grad_fn=<NllLossBackward>)
    ===========================
    173500 iterations have been completed!
         --> Now loss =  tensor(0.0101, grad_fn=<NllLossBackward>)
    ===========================
    174000 iterations have been completed!
         --> Now loss =  tensor(0.0101, grad_fn=<NllLossBackward>)
    ===========================
    174500 iterations have been completed!
         --> Now loss =  tensor(0.0101, grad_fn=<NllLossBackward>)
    ===========================
    175000 iterations have been completed!
         --> Now loss =  tensor(0.0101, grad_fn=<NllLossBackward>)
    ===========================
    175500 iterations have been completed!
         --> Now loss =  tensor(0.0101, grad_fn=<NllLossBackward>)
    ===========================
    176000 iterations have been completed!
         --> Now loss =  tensor(0.0101, grad_fn=<NllLossBackward>)
    ===========================
    176500 iterations have been completed!
         --> Now loss =  tensor(0.0101, grad_fn=<NllLossBackward>)
    ===========================
    177000 iterations have been completed!
         --> Now loss =  tensor(0.0101, grad_fn=<NllLossBackward>)
    ===========================
    177500 iterations have been completed!
         --> Now loss =  tensor(0.0100, grad_fn=<NllLossBackward>)
    ===========================
    178000 iterations have been completed!
         --> Now loss =  tensor(0.0100, grad_fn=<NllLossBackward>)
    ===========================
    178500 iterations have been completed!
         --> Now loss =  tensor(0.0100, grad_fn=<NllLossBackward>)
    ===========================
    179000 iterations have been completed!
         --> Now loss =  tensor(0.0100, grad_fn=<NllLossBackward>)
    ===========================
    179500 iterations have been completed!
         --> Now loss =  tensor(0.0100, grad_fn=<NllLossBackward>)
    ===========================
    180000 iterations have been completed!
         --> Now loss =  tensor(0.0100, grad_fn=<NllLossBackward>)
    ===========================
    180500 iterations have been completed!
         --> Now loss =  tensor(0.0100, grad_fn=<NllLossBackward>)
    ===========================
    181000 iterations have been completed!
         --> Now loss =  tensor(0.0100, grad_fn=<NllLossBackward>)
    ===========================
    181500 iterations have been completed!
         --> Now loss =  tensor(0.0100, grad_fn=<NllLossBackward>)
    ===========================
    182000 iterations have been completed!
         --> Now loss =  tensor(0.0100, grad_fn=<NllLossBackward>)
    ===========================

```python
'''
（1）如果tensor只有一个元素，然后转换成int或者float类型的时候直接用int()或者float()就可以了；

（2）如果tensor含有多个元素，转换成ndarray时就要用x.detach().numpy()操作了（视情况使用,cpu()）；
'''
loss_list1 = [float(x.detach()) for x in loss_list]
loss_list1
```

    [0.800163984298706,
     0.8309003114700317,
     0.8131172060966492,
     0.8071346282958984,
     0.7703815698623657,
     0.7530996203422546,
     0.729813277721405,
     0.7179836630821228,
     0.7069706916809082,
     0.7009865045547485,
     0.6962601542472839,
     0.6935564279556274,
     0.6915972828865051,
     0.6904343366622925,
     0.6896310448646545,
     0.6891406178474426,
     0.6888116598129272,
     0.6886079907417297,
     0.6884725689888,
     0.6883881092071533,
     0.6883326172828674,
     0.6882973909378052,
     0.6882752776145935,
     0.6882601380348206,
     0.6882511973381042,
     0.688244104385376,
     0.6882399916648865,
     0.6882373094558716,
     0.6882364749908447,
     0.6882348656654358,
     0.6882333755493164,
     0.6882334351539612,
     0.6882322430610657,
     0.6882324814796448,
     0.688231885433197,
     0.6882319450378418,
     0.6882314085960388,
     0.6882311701774597,
     0.6882303357124329,
     0.6882304549217224,
     0.6882301568984985,
     0.6882299780845642,
     0.6882299780845642,
     0.6882292032241821,
     0.6882297396659851,
     0.6882290244102478,
     0.6882290840148926,
     0.6882284283638,
     0.6882277727127075,
     0.6882278323173523,
     0.6882275938987732,
     0.6882275938987732,
     0.6882274150848389,
     0.6882275938987732,
     0.6882266402244568,
     0.6882265210151672,
     0.6882257461547852,
     0.6882256865501404,
     0.6882250308990479,
     0.6882250308990479,
     0.6882250905036926,
     0.6882244348526001,
     0.6882243156433105,
     0.688223659992218,
     0.6882237792015076,
     0.6882233619689941,
     0.6882230639457703,
     0.6882225871086121,
     0.6882220506668091,
     0.68822181224823,
     0.6882215142250061,
     0.6882213950157166,
     0.6882213354110718,
     0.6882209181785583,
     0.6882205605506897,
     0.6882204413414001,
     0.6882203817367554,
     0.6882203221321106,
     0.6882201433181763,
     0.6882199048995972,
     0.6882196664810181,
     0.688219428062439,
     0.6882193088531494,
     0.6882190704345703,
     0.6882190704345703,
     0.6882188320159912,
     0.6882186532020569,
     0.6882184743881226,
     0.688218355178833,
     0.6882181763648987,
     0.6882176995277405,
     0.6882175207138062,
     0.6882172226905823,
     0.6882169842720032,
     0.6882168054580688,
     0.6882166266441345,
     0.6882161498069763,
     0.6882157325744629,
     0.6882154941558838,
     0.6882154941558838,
     0.6882153153419495,
     0.6882150173187256,
     0.6882147192955017,
     0.6882145404815674,
     0.6882142424583435,
     0.6882140040397644,
     0.6882137656211853,
     0.6882135272026062,
     0.6882132887840271,
     0.6882132887840271,
     0.6882131099700928,
     0.6882128715515137,
     0.6882126331329346,
     0.6882123351097107,
     0.6882121562957764,
     0.688211977481842,
     0.6882117986679077,
     0.6882115602493286,
     0.6882113814353943,
     0.6882109642028809,
     0.6882109045982361,
     0.6882108449935913,
     0.6882109045982361,
     0.6882106065750122,
     0.688210129737854,
     0.6882101893424988,
     0.6882098913192749,
     0.6882098317146301,
     0.688209593296051,
     0.6882092952728271,
     0.6882091760635376,
     0.6882089972496033,
     0.6882088780403137,
     0.6882086396217346,
     0.6882083415985107,
     0.6882081627845764,
     0.6882080435752869,
     0.6882079243659973,
     0.6882078051567078,
     0.6882075071334839,
     0.6882073283195496,
     0.6882071495056152,
     0.6882068514823914,
     0.6882067322731018,
     0.6882063746452332,
     0.6882060766220093,
     0.6882057785987854,
     0.6882057785987854,
     0.6882055997848511,
     0.688205361366272,
     0.6882051825523376,
     0.6882050037384033,
     0.6882047653198242,
     0.6882046461105347,
     0.6882046461105347,
     0.6882044672966003,
     0.6882044076919556,
     0.6882044076919556,
     0.6882045269012451,
     0.6882042288780212,
     0.6882041096687317,
     0.6882039308547974,
     0.6882036924362183,
     0.6882035732269287,
     0.6882035136222839,
     0.6882032752037048,
     0.6882032752037048,
     0.688202977180481,
     0.6882026791572571,
     0.6882025003433228,
     0.6882023811340332,
     0.6882023811340332,
     0.6882025003433228,
     0.6882023215293884,
     0.6882020235061646,
     0.6882016658782959,
     0.6882015466690063,
     0.6882014274597168,
     0.6882014274597168,
     0.6882014274597168,
     0.6882014274597168,
     0.688201367855072,
     0.6882010102272034,
     0.688200831413269,
     0.6882005929946899,
     0.6882004141807556,
     0.6882004141807556,
     0.6882004737854004,
     0.6882003545761108,
     0.6882002353668213,
     0.6882001161575317,
     0.6881997585296631,
     0.6881997585296631,
     0.6881995797157288,
     0.6881993412971497,
     0.6881991624832153,
     0.6881993412971497,
     0.6881992220878601,
     0.6881991624832153,
     0.6881992220878601,
     0.6881991624832153,
     0.6881991624832153,
     0.688198983669281,
     0.6881985664367676,
     0.688198447227478,
     0.6881983280181885,
     0.6881981492042542,
     0.6881978511810303,
     0.6881977915763855,
     0.6881975531578064,
     0.6881974339485168,
     0.688197135925293,
     0.6881967782974243,
     0.68819659948349,
     0.6881964802742004,
     0.6881964206695557,
     0.688196063041687,
     0.6881957650184631,
     0.6881957650184631,
     0.6881956458091736,
     0.6881959438323975,
     0.6881957650184631,
     0.6881955862045288,
     0.6881952881813049,
     0.6881951093673706,
     0.6881950497627258,
     0.6881948709487915,
     0.6881946921348572,
     0.6881945133209229,
     0.6881941556930542,
     0.6881939172744751,
     0.6881937384605408,
     0.6881937384605408,
     0.6881937384605408,
     0.6881935596466064,
     0.6881935596466064,
     0.6881933212280273,
     0.6881932020187378,
     0.6881929636001587,
     0.68819260597229,
     0.6881923079490662,
     0.6881922483444214,
     0.6881921887397766,
     0.688191831111908,
     0.6881917119026184,
     0.6881916522979736,
     0.6881913542747498,
     0.6881912350654602,
     0.6881912350654602,
     0.688191294670105,
     0.6881909966468811,
     0.6881906986236572,
     0.688190758228302,
     0.6881905794143677,
     0.6881905794143677,
     0.6881903409957886,
     0.6881902813911438,
     0.688190221786499,
     0.6881901621818542,
     0.6881899237632751,
     0.6881899833679199,
     0.6881896257400513,
     0.6881893873214722,
     0.6881894469261169,
     0.6881890296936035,
     0.6881887912750244,
     0.6881884932518005,
     0.6881882548332214,
     0.6881879568099976,
     0.6881876587867737,
     0.6881873607635498,
     0.6881870031356812,
     0.6881870031356812,
     0.688186764717102,
     0.6881867051124573,
     0.688186526298523,
     0.6881863474845886,
     0.6881860494613647,
     0.6881860494613647,
     0.6881857514381409,
     0.6881856918334961,
     0.688185453414917,
     0.6881853342056274,
     0.6881853342056274,
     0.6881846785545349,
     0.6881844997406006,
     0.6881844401359558,
     0.6881841421127319,
     0.6881839632987976,
     0.6881836652755737,
     0.6881836652755737,
     0.6881833076477051,
     0.6881829500198364,
     0.688183069229126,
     0.688183069229126,
     0.6881826519966125,
     0.6881824731826782,
     0.6881822943687439,
     0.6881822347640991,
     0.6881820559501648,
     0.6881820559501648,
     0.68818199634552,
     0.6881818175315857,
     0.6881816387176514,
     0.6881813406944275,
     0.6881812810897827,
     0.6881809830665588,
     0.6881809234619141,
     0.6881807446479797,
     0.6881805658340454,
     0.6881805658340454,
     0.6881802082061768,
     0.6881798505783081,
     0.6881795525550842,
     0.6881792545318604,
     0.688179075717926,
     0.6881786584854126,
     0.6881784200668335,
     0.6881783604621887,
     0.6881782412528992,
     0.6881781220436096,
     0.6881778836250305,
     0.6881776452064514,
     0.688177764415741,
     0.6881777048110962,
     0.6881777048110962,
     0.6881774067878723,
     0.688177227973938,
     0.6881769895553589,
     0.6881768703460693,
     0.6881766319274902,
     0.6881762742996216,
     0.6881762146949768,
     0.6881759762763977,
     0.6881757378578186,
     0.6881755590438843,
     0.6881754994392395,
     0.68817538022995,
     0.6881754994392395,
     0.6881754398345947,
     0.6881753206253052,
     0.6881752014160156,
     0.6881750822067261,
     0.6881750822067261,
     0.6881749033927917,
     0.6881747245788574,
     0.6881746053695679,
     0.6881744265556335,
     0.6881742477416992,
     0.6881741285324097,
     0.6881740689277649,
     0.688173770904541,
     0.688173770904541,
     0.688173770904541,
     0.6881737112998962,
     0.6881734728813171,
     0.6881732940673828,
     0.688173234462738,
     0.6881728768348694,
     0.6881727576255798,
     0.6881725192070007,
     0.688172459602356,
     0.6881721019744873,
     0.6881717443466187,
     0.68817138671875,
     0.6881712675094604,
     0.6881712079048157,
     0.6881710886955261,
     0.6881710290908813,
     0.688170850276947,
     0.688170313835144,
     0.6881703734397888,
     0.688170313835144,
     0.6881698966026306,
     0.6881697177886963,
     0.688169538974762,
     0.6881694197654724,
     0.6881691813468933,
     0.6881690621376038,
     0.6881687641143799,
     0.6881685256958008,
     0.688168466091156,
     0.6881684064865112,
     0.6881680488586426,
     0.6881680488586426,
     0.6881676912307739,
     0.6881679892539978,
     0.6881680488586426,
     0.688167929649353,
     0.6881678700447083,
     0.68816739320755,
     0.6881673336029053,
     0.6881673336029053,
     0.6881672143936157,
     0.6881670951843262,
     0.6881666779518127,
     0.6881665587425232,
     0.6881663203239441,
     0.6881663799285889,
     0.6881659030914307,
     0.6881658434867859,
     0.6881656050682068,
     0.6881654262542725,
     0.6881652474403381,
     0.6881652474403381,
     0.6881652474403381,
     0.6881649494171143,
     0.6881647706031799,
     0.6881647706031799,
     0.6881646513938904,
     0.688164472579956,
     0.688164234161377,
     0.6881641745567322,
     0.6881639957427979,
     0.6881638765335083,
     0.6881635189056396,
     0.6881632804870605,
     0.6881629824638367,
     0.688162624835968,
     0.6881625652313232,
     0.6881625652313232,
     0.6881621479988098,
     0.6881622076034546,
     0.6881620287895203,
     0.6881619095802307,
     0.6881619095802307,
     0.6881618499755859,
     0.6881617307662964,
     0.6881614923477173,
     0.6881612539291382,
     0.6881611347198486,
     0.6881610751152039,
     0.68816077709198,
     0.6881607174873352,
     0.6881605386734009,
     0.6881601810455322,
     0.6881600618362427,
     0.6881600618362427,
     0.6881601214408875,
     0.6881600022315979,
     0.6881598830223083,
     0.6881597638130188,
     0.6881595849990845,
     0.6881596446037292,
     0.6881594657897949,
     0.688159167766571,
     0.6881588697433472,
     0.6881585121154785,
     0.6881582736968994,
     0.6881581544876099,
     0.6881577372550964,
     0.6881576180458069,
     0.6881574988365173,
     0.6881572008132935,
     0.6881571412086487,
     0.6881569623947144,
     0.6881568431854248,
     0.68815678358078,
     0.6881564855575562,
     0.6881563663482666,
     0.6881563067436218,
     0.6881561875343323,
     0.688156008720398,
     0.6881560683250427,
     0.6881557106971741,
     0.688155472278595,
     0.6881552934646606,
     0.6881552934646606,
     0.6881550550460815,
     0.6881550550460815,
     0.6881548762321472,
     0.6881547570228577,
     0.6881546378135681,
     0.6881545782089233,
     0.6881544589996338,
     0.6881543397903442,
     0.6881542801856995,
     0.6881541609764099,
     0.6881542205810547,
     0.6881541013717651,
     0.6881538033485413,
     0.6881538033485413,
     0.6881533861160278,
     0.6881533265113831,
     0.6881531476974487,
     0.6881528496742249,
     0.6881529092788696,
     0.6881527900695801,
     0.688152551651001,
     0.688152551651001,
     0.6881521940231323,
     0.688152015209198,
     0.6881517171859741,
     0.6881516575813293,
     0.6881515383720398,
     0.6881512403488159,
     0.6881510019302368,
     0.6881508231163025,
     0.6881507635116577,
     0.6881505846977234,
     0.6881505846977234,
     0.6881504058837891,
     0.6881503462791443,
     0.6881502270698547,
     0.6881502270698547,
     0.6881501078605652,
     0.6881498694419861,
     0.6881496906280518,
     0.688149631023407,
     0.6881493330001831,
     0.6881492137908936,
     0.688149094581604,
     0.6881489753723145,
     0.6881488561630249,
     0.6881486177444458,
     0.6881484985351562,
     0.6881484389305115,
     0.6881481409072876,
     0.6881478428840637,
     0.6881476640701294,
     0.6881474852561951,
     0.6881474256515503,
     0.6881471872329712,
     0.6881469488143921,
     0.6881469488143921,
     0.6881469488143921,
     0.6881467700004578,
     0.6881467700004578,
     0.688146710395813,
     0.6881465315818787,
     0.6881464719772339,
     0.6881462335586548,
     0.6881458759307861,
     0.6881458759307861,
     0.6881456971168518,
     0.688145637512207,
     0.6881455779075623,
     0.6881454586982727,
     0.6881452798843384,
     0.6881452202796936,
     0.6881449818611145,
     0.688145101070404,
     0.6881449818611145,
     0.6881447434425354,
     0.6881445646286011,
     0.688144326210022,
     0.6881442666053772,
     0.6881440877914429,
     0.6881439685821533,
     0.6881436705589294,
     0.6881434917449951,
     0.6881433725357056,
     0.6881431937217712,
     0.6881430149078369,
     0.6881430149078369,
     0.6881430745124817,
     0.6881430745124817,
     0.6881430745124817,
     0.6881428360939026,
     0.6881424784660339,
     0.6881423592567444,
     0.6881422400474548,
     0.6881420612335205,
     0.6881418824195862,
     0.6881416440010071,
     0.688141405582428,
     0.6881412267684937,
     0.6881409883499146,
     0.6881410479545593,
     0.6881409287452698,
     0.6881409287452698,
     0.6881402730941772,
     0.6881401538848877,
     0.688139796257019,
     0.6881394386291504,
     0.6881394982337952,
     0.6881394386291504,
     0.688139021396637,
     0.688139021396637,
     0.6881387829780579,
     0.6881386041641235,
     0.6881383061408997,
     0.6881380677223206,
     0.6881380081176758,
     0.688137948513031,
     0.6881378889083862,
     0.6881376504898071,
     0.6881374716758728,
     0.6881375312805176,
     0.6881375908851624,
     0.6881374716758728,
     0.6881372928619385,
     0.6881371140480042,
     0.6881368160247803,
     0.6881368160247803,
     0.688136637210846,
     0.6881364583969116,
     0.688136100769043,
     0.6881355047225952,
     0.6881353855133057,
     0.6881354451179504,
     0.6881353855133057,
     0.6881350874900818,
     0.688135027885437,
     0.6881346702575684,
     0.6881347298622131,
     0.6881346702575684,
     0.6881343722343445,
     0.6881341338157654,
     0.688133955001831,
     0.6881338953971863,
     0.6881338357925415,
     0.6881338953971863,
     0.6881336569786072,
     0.6881332993507385,
     0.6881331205368042,
     0.6881329417228699,
     0.6881328821182251,
     0.688132643699646,
     0.6881325244903564,
     0.6881324648857117,
     0.6881323456764221,
     0.6881322264671326,
     0.6881320476531982,
     0.6881317496299744,
     0.6881318688392639,
     0.6881316900253296,
     0.6881315112113953,
     0.6881312727928162,
     0.6881310343742371,
     0.6881309747695923,
     0.6881308555603027,
     0.6881307363510132,
     0.6881304383277893,
     0.6881303191184998,
     0.688130259513855,
     0.6881303787231445,
     0.6881300806999207,
     0.6881300210952759,
     0.6881299614906311,
     0.6881298422813416,
     0.6881294846534729,
     0.6881291270256042,
     0.6881290078163147,
     0.6881290674209595,
     0.6881289482116699,
     0.6881288886070251,
     0.6881284713745117,
     0.6881284713745117,
     0.6881282329559326,
     0.6881281137466431,
     0.6881275773048401,
     0.6881276369094849,
     0.6881272792816162,
     0.6881271004676819,
     0.688126802444458,
     0.6881266832351685,
     0.6881266832351685,
     0.6881265044212341,
     0.6881263256072998,
     0.6881260275840759,
     0.6881259083747864,
     0.6881258487701416,
     0.6881257891654968,
     0.688125491142273,
     0.6881254315376282,
     0.6881253719329834,
     0.6881253123283386,
     0.6881250739097595,
     0.6881248354911804,
     0.6881247162818909,
     0.6881247162818909,
     0.6881246566772461,
     0.6881247162818909,
     0.688124418258667,
     0.6881240010261536,
     0.688123881816864,
     0.6881235837936401,
     0.6881234645843506,
     0.6881234645843506,
     0.688123345375061,
     0.6881229877471924,
     0.6881229877471924,
     0.6881226301193237,
     0.6881227493286133,
     0.688122570514679,
     0.6881224513053894,
     0.6881221532821655,
     0.688122034072876,
     0.6881217956542969,
     0.6881219148635864,
     0.6881219148635864,
     0.6881218552589417,
     0.6881216168403625,
     0.6881211996078491,
     0.6881210803985596,
     0.6881208419799805,
     0.6881207227706909,
     0.6881206035614014,
     0.6881204843521118,
     0.6881203055381775,
     0.6881203055381775,
     0.6881200075149536,
     0.6881199479103088,
     0.6881197094917297,
     0.6881195306777954,
     0.6881194114685059,
     0.6881189942359924,
     0.6881186366081238,
     0.6881183981895447,
     0.6881183385848999,
     0.6881183981895447,
     0.6881181597709656,
     0.6881179809570312,
     0.6881177425384521,
     0.6881176233291626,
     0.6881173849105835,
     0.6881169080734253,
     0.6881167888641357,
     0.6881166100502014,
     0.688116729259491,
     0.6881164908409119,
     0.688116192817688,
     0.6881160736083984,
     0.6881160140037537,
     0.688115656375885,
     0.6881155371665955,
     0.6881154179573059,
     0.6881151795387268,
     0.6881151795387268,
     0.6881149411201477,
     0.6881148815155029,
     0.6881148219108582,
     0.6881146430969238,
     0.6881144046783447,
     0.6881141662597656,
     0.6881141066551208,
     0.6881141066551208,
     0.6881138682365417,
     0.6881138682365417,
     0.6881136298179626,
     0.6881135702133179,
     0.6881136298179626,
     0.6881132125854492,
     0.6881129145622253,
     0.688112735748291,
     0.6881123781204224,
     0.6881124377250671,
     0.6881122589111328,
     0.6881116628646851,
     0.6881113052368164,
     0.688111424446106,
     0.6881113052368164,
     0.6881110072135925,
     0.6881110072135925,
     0.6881108283996582,
     0.6881107091903687,
     0.6881109476089478,
     0.688110888004303,
     0.6881104707717896,
     0.6881102919578552,
     0.688109815120697,
     0.6881097555160522,
     0.6881095170974731,
     0.6881094574928284,
     0.6881090402603149,
     0.6881089210510254,
     0.6881087422370911,
     0.6881084442138672,
     0.6881082653999329,
     0.6881081461906433,
     0.6881077885627747,
     0.6881078481674194,
     0.688107967376709,
     0.6881078481674194,
     0.6881077289581299,
     0.6881076097488403,
     0.6881073117256165,
     0.6881070733070374,
     0.688106894493103,
     0.6881064772605896,
     0.6881062388420105,
     0.6881057024002075,
     0.688105583190918,
     0.6881057024002075,
     0.688105583190918,
     0.688105583190918,
     0.6881051659584045,
     0.6881051659584045,
     0.688105046749115,
     0.6881049871444702,
     0.6881047487258911,
     0.6881043314933777,
     0.6881041526794434,
     0.6881036758422852,
     0.6881033182144165,
     0.6881030201911926,
     0.6881030797958374,
     0.6881029605865479,
     0.6881027817726135,
     0.688102662563324,
     0.6881027221679688,
     0.6881024241447449,
     0.6881022453308105,
     0.6881021857261658,
     0.6881020069122314,
     0.6881019473075867,
     0.6881016492843628,
     0.6881012916564941,
     0.6881011128425598,
     0.6881009936332703,
     0.6881006956100464,
     0.6881003975868225,
     0.6881003975868225,
     0.6881005764007568,
     0.6881005764007568,
     0.6881005167961121,
     0.6881003379821777,
     0.6881001591682434,
     0.6880999803543091,
     0.6880995035171509,
     0.6880990862846375,
     0.6880989074707031,
     0.6880987286567688,
     0.6880983710289001,
     0.6880983114242554,
     0.6880980730056763,
     0.6880980134010315,
     0.6880978941917419,
     0.6880975365638733,
     0.6880972981452942,
     0.6880972385406494,
     0.6880968809127808,
     0.6880967020988464,
     0.6880966424942017,
     0.6880963444709778,
     0.6880961656570435,
     0.6880962252616882,
     0.6880958676338196,
     0.68809574842453,
     0.6880956888198853,
     0.6880955100059509,
     0.6880953311920166,
     0.6880954504013062,
     0.6880953907966614,
     0.6880950927734375,
     0.688094973564148,
     0.6880947947502136,
     0.6880946755409241,
     0.6880943179130554,
     0.6880943179130554,
     0.6880942583084106,
     0.6880940794944763,
     0.6880941390991211,
     0.6880939602851868,
     0.6880937218666077,
     0.6880934238433838,
     0.6880931854248047,
     0.6880929470062256,
     0.6880926489830017,
     0.6880925893783569,
     0.6880923509597778,
     0.6880923509597778,
     0.6880919933319092,
     0.6880919337272644,
     0.6880916953086853,
     0.6880914568901062,
     0.6880913376808167,
     0.6880909204483032,
     0.6880908608436584,
     0.6880905628204346,
     0.6880903244018555,
     0.6880903244018555,
     0.6880899667739868,
     0.6880896687507629,
     0.6880894303321838,
     0.6880894303321838,
     0.68808913230896,
     0.6880890727043152,
     0.6880885362625122,
     0.6880887150764465,
     0.6880882978439331,
     0.6880879402160645,
     0.6880877017974854,
     0.6880873441696167,
     0.6880869269371033,
     0.6880865693092346,
     0.6880865693092346,
     0.6880865097045898,
     0.6880864500999451,
     0.6880860924720764,
     0.6880858540534973,
     0.6880857348442078,
     0.6880853176116943,
     0.6880851984024048,
     0.6880852580070496,
     0.6880850195884705,
     0.6880848407745361,
     0.6880844831466675,
     0.6880843043327332,
     0.6880843043327332,
     0.688084065914154,
     0.6880841255187988,
     0.6880839467048645,
     0.6880836486816406,
     0.6880833506584167,
     0.6880830526351929,
     0.6880829930305481,
     0.6880828142166138,
     0.6880825161933899,
     0.6880825161933899,
     0.6880821585655212,
     0.6880821585655212,
     0.6880817413330078,
     0.688081681728363,
     0.6880815625190735,
     0.6880811452865601,
     0.688080906867981,
     0.6880807876586914,
     0.6880806088447571,
     0.6880805492401123,
     0.6880805492401123,
     0.6880803108215332,
     0.6880802512168884,
     0.6880798935890198,
     0.6880795955657959,
     0.6880791783332825,
     0.6880789995193481,
     0.688078761100769,
     0.6880782246589661,
     0.6880780458450317,
     0.6880781054496765,
     0.6880778670310974,
     0.6880777478218079,
     0.6880775690078735,
     0.6880776286125183,
     0.6880771517753601,
     0.6880769729614258,
     0.688076913356781,
     0.6880766153335571,
     0.6880761981010437,
     0.688075840473175,
     0.6880756616592407,
     0.6880753636360168,
     0.6880753636360168,
     0.6880751848220825,
     0.6880750060081482,
     0.6880748867988586,
     0.6880745887756348,
     0.6880742311477661,
     0.6880739331245422,
     0.6880736351013184,
     0.6880733966827393,
     0.6880735158920288,
     0.6880732178688049,
     0.6880732178688049,
     0.688072919845581,
     0.6880725622177124,
     0.6880722045898438,
     0.6880719661712646,
     0.6880718469619751,
     0.6880714893341064,
     0.6880713105201721,
     0.688071072101593,
     0.6880707740783691,
     0.6880702972412109,
     0.6880701184272766,
     0.6880696415901184,
     0.6880691647529602,
     0.6880690455436707,
     0.6880690455436707,
     0.6880691051483154,
     0.6880687475204468,
     0.688068687915802,
     0.6880685091018677,
     0.6880685687065125,
     0.6880683898925781,
     0.6880682110786438,
     0.6880680322647095,
     0.6880676746368408,
     0.6880674958229065,
     0.6880674362182617,
     0.6880670785903931,
     0.6880670189857483,
     0.6880666613578796,
     0.6880663633346558,
     0.6880664229393005,
     0.6880661845207214,
     0.6880662441253662,
     0.6880658864974976,
     0.6880655884742737,
     0.6880652904510498,
     0.6880650520324707,
     0.6880649924278259,
     0.6880645751953125,
     0.688064455986023,
     0.6880640983581543,
     0.6880639791488647,
     0.6880636215209961,
     0.6880635023117065,
     ...]

```python
'''
画出损失函数图像
'''
import matplotlib.pyplot as plt
plt.figure(figsize=(16,8))
length = loss_list.__len__()
print('The length of loss_list is:',length)
plt.plot(np.arange(0,15000,2),loss_list1[:15000],'black')
plt.xlabel('epoch')
plt.ylabel('loss')
plt.show()
```

Softmax是一个产生激活作用的概率分布密度函数
为什么dim需要等于1？
首先dim=1意思是使得在softmax操作之后在dim这个维度相加等于1

```python
Probability_Calculator = nn.Softmax(dim=1)
pred = []
# x.detach()都是从原有计算中分离出来的一个tensor变量,但是没有更改这个tensor时，并不会影响backward()
# numpy()将tensor转变为array数组
prob = Probability_Calculator(DNN_Model.forward(x)).detach().numpy()
```

```python
prob
```

    array([[9.9793446e-01, 2.0654975e-03],
           [9.9741769e-01, 2.5823605e-03],
           [3.5692580e-08, 1.0000000e+00],
           ...,
           [9.9813253e-01, 1.8674860e-03],
           [6.5254078e-08, 9.9999988e-01],
           [9.9962485e-01, 3.7512733e-04]], dtype=float32)

>>> import numpy as np
>>> y = np.array([[1,2,3],[4,5,6]])
>>> print(y)
[[1 2 3]
 [4 5 6]]
>>> print(y.shape) # 展示行数，列数
(2, 3)
>>> print(y.shape[0]) # 展示行数
2
>>> print(y.shape[1]) # 展示列数
3

```python
for i in range(prob.shape[0]):
    pred.append(np.argmax(prob[i,:]))  #np.argmax()最大值的索引
pred = np.array(pred)
pred
```

    array([0, 0, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 1, 0, 0, 0,
           1, 1, 0, 1, 0, 1, 1, 1, 0, 0, 1, 0, 0, 1, 0, 1, 1, 1, 1, 1, 1, 0,
           0, 0, 1, 0, 0, 1, 1, 1, 0, 1, 1, 0, 1, 1, 1, 1, 1, 0, 0, 0, 1, 0,
           0, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0,
           0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 1, 1, 1, 1,
           0, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 0, 1, 0, 0, 0, 1, 0, 1, 1, 0, 1,
           1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 1,
           1, 1, 0, 1, 0, 0, 1, 0, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1,
           0, 1, 1, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 0, 1, 1, 1, 0, 1, 0, 1, 0,
           1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1,
           0, 1, 1, 1, 0, 0, 0, 1, 0, 0, 1, 0, 0, 1, 1, 0, 0, 0, 1, 0, 0, 0,
           1, 0, 0, 1, 1, 1, 0, 0, 1, 1, 1, 1, 0, 1, 0, 0, 0, 1, 0, 1, 1, 1,
           0, 0, 1, 1, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 0,
           1, 1, 0, 0, 0, 0, 1, 0, 1, 1, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 0, 0,
           1, 1, 1, 1, 0, 1, 1, 1, 1, 0, 1, 1, 0, 0, 1, 1, 1, 1, 0, 1, 0, 0,
           1, 0, 0, 1, 0, 0, 1, 1, 0, 0, 1, 1, 1, 1, 0, 1, 0, 1, 0, 0, 1, 0,
           0, 1, 1, 1, 1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0,
           1, 1, 0, 0, 1, 1, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0,
           1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0,
           1, 0, 0, 1, 1, 1, 1, 0, 0, 0, 1, 0, 1, 1, 0, 0, 1, 0, 0, 1, 0, 1,
           0, 0, 0, 1, 0, 1, 0, 0, 1, 1, 1, 0, 1, 0, 0, 0, 1, 1, 0, 0, 1, 0,
           1, 1, 0, 1, 1, 0, 0, 0, 0, 1, 1, 0, 1, 1, 0, 1, 0, 0, 1, 1, 1, 1,
           1, 1, 1, 1, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0,
           1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1, 1, 1,
           0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 0, 1, 1, 0, 0, 1, 0, 1, 1, 1, 1,
           0, 1, 1, 0, 1, 0, 1, 1, 1, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 1, 0, 1,
           1, 1, 0, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 0, 0, 1, 0, 1, 0,
           0, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 0, 1, 1, 1, 0, 0, 1, 0, 0, 0,
           1, 0, 1, 1, 0, 1, 1, 1, 1, 1, 0, 1, 0, 1, 1, 1, 1, 0, 0, 1, 0, 1,
           1, 1, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0,
           1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 1, 0, 1, 0, 0, 0, 0, 1, 1, 0, 1,
           1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 1, 1, 1, 0, 1, 0,
           1, 1, 0, 0, 1, 1, 1, 1, 0, 1, 0, 0, 0, 1, 0, 1, 1, 1, 1, 1, 0, 1,
           0, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0, 1, 1, 1, 0, 1, 0, 0, 1, 1, 1,
           1, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 0, 1, 1, 1, 1, 1, 0, 1, 1, 0, 0,
           0, 1, 1, 1, 0, 0, 0, 0, 1, 1, 0, 1, 1, 0, 1, 0, 0, 0, 1, 1, 1, 1,
           1, 1, 1, 1, 1, 0, 0, 1, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 1, 0, 1, 0,
           0, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 0, 1, 0, 1, 0, 0, 0, 1, 1, 0, 0,
           1, 1, 0, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1,
           1, 0, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 1, 0, 0, 1, 0, 1, 1, 0, 0, 0,
           0, 1, 1, 1, 1, 1, 1, 0, 0, 1, 0, 1, 1, 0, 1, 1, 1, 0, 0, 1, 0, 1,
           1, 0, 0, 0, 0, 1, 0, 1, 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 1, 1, 0,
           1, 1, 0, 0, 1, 1, 1, 0, 1, 1, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 0, 0,
           0, 1, 0, 0, 1, 0, 1, 1, 0, 0, 0, 1, 1, 0, 0, 0, 0, 1, 0, 1, 0, 0,
           0, 0, 1, 0, 1, 0, 0, 1, 1, 1, 0, 1, 1, 0, 0, 0, 0, 1, 1, 1, 0, 0,
           0, 0, 1, 0, 0, 0, 0, 1, 0], dtype=int64)

```python
Probability_Calculator = nn.Softmax(dim=1)   # softmax的dim这个参数 意思就是使得在softmax操作之后在dim这个维度相加等于1
pred = []
# x.detach()都是从原有计算中分离出来的一个tensor变量,但是没有更改这个tensor时，并不会影响backward()
# numpy()将tensor转变为array数组
prob = Probability_Calculator(DNN_Model.forward(x)).detach().numpy()
# numpy.argmax(array, axis) 用于返回一个numpy数组中最大值的索引值。当一组中同时出现几个最大值时，返回第一个最大值的索引值。
for i in range(prob.shape[0]):
    pred.append(np.argmax(prob[i,:]))

pred = np.array(pred)
pred.shape
accuracy_score(pred,y)
```

    0.998998998998999

## **Prediction，Backtesting，Computing Gain/loss**

```python
x = test_set.iloc[:,0:24]
y = test_set.iloc[:,24]
x = np.array(x)
y = np.array(y)
x = Variable(torch.FloatTensor(x))
y = Variable(torch.LongTensor(y))
```

```python
Probability_Calculator = nn.Softmax(dim=1)
pred = []
prob = Probability_Calculator(DNN_Model.forward(x)).detach().numpy()
for i in range(prob.shape[0]):
    if np.max(prob[i,:]) >= 0.95:
        pred.append(np.argmax(prob[i,:]))
    else:
        pred.append(np.nan)
pred = np.array(pred)
```

```python
pred
```

    array([ 0.,  1.,  0.,  1.,  0.,  1., nan, nan,  0.,  0., nan,  1.,  1.,
            0.,  0., nan,  0., nan,  0.,  0.,  0.,  0.,  0.,  1.,  1.,  0.,
           nan,  1.,  0.,  0.,  0.,  0.,  1.,  0.,  1.,  1.,  1.,  0.,  1.,
            0.,  1.,  1.,  0.,  1.,  0.,  0.,  0.,  1.,  1.,  0.,  1.,  1.,
            0.,  0.,  1.,  0.,  1.,  1.,  1.,  0.,  0.,  1.,  0.,  1.,  1.,
            1.,  0.,  0.,  0.,  0.,  1.,  1.,  1.,  0.,  0., nan,  1.,  0.,
            1.,  1.,  1.,  1.,  1.,  1., nan,  1.,  1.,  0.,  0.,  1.,  1.,
           nan,  0.,  0.,  0.,  0.,  0.,  0.,  1.,  0.,  1.,  1.,  0.,  0.,
            0.,  0.,  1., nan,  0.,  0.,  0.,  0.,  0.,  0.,  1.,  1.,  1.,
            1.,  0.,  0.,  0., nan,  1., nan,  1.,  0.,  1.,  0.,  1.,  0.,
           nan,  0.,  1.,  0.,  0.,  0.,  1.,  0.,  0.,  0.,  0.,  1.,  0.,
            1.,  1.,  1.,  1.,  0.,  1.,  0.,  0.,  0.,  1.,  1.,  1.,  1.,
            1.,  0.,  1.,  0.,  0.,  1.,  1.,  0.,  0.,  1.,  0.,  0.,  1.,
            0.,  1.,  0.,  1.,  1., nan,  1.,  0.,  1.,  1.,  0.,  1.,  1.,
            0., nan,  1.,  0.,  1.,  1., nan,  1.,  1.,  0.,  1.,  0.,  0.,
            1.,  0.,  1.,  1.,  1.,  1.,  1.,  1., nan,  0.,  0.,  0.,  1.,
            1.,  1.,  0.,  0.,  0., nan,  0.,  0.,  1.,  1.,  1.,  1.,  1.,
            0.,  0.,  1.,  0.,  0.,  0.,  1.,  0.,  0., nan,  1.,  0.,  1.,
            1.,  0.,  1., nan,  0., nan,  1., nan,  1.,  1., nan,  1., nan,
           nan,  0., nan,  0.,  0.,  1.,  1.,  0.,  1.,  0.,  1.,  1.,  0.,
            0., nan,  1.,  1.,  1.,  0., nan,  1.,  0.,  0.,  1.,  1.,  1.,
            0.,  0., nan,  1.,  1.,  1.,  0., nan,  1.,  1., nan,  1.,  0.,
            0.,  0.,  0., nan,  1.,  0.,  1.,  1.,  0.,  0.,  0.,  0.,  0.,
           nan,  1.,  1.,  1.,  0.,  1.,  0.,  1.,  1.,  1.,  0.,  0.,  1.,
            1.,  0.,  1.,  0., nan,  0.,  0.,  1., nan,  0.,  1.,  1.,  1.,
            1.,  1.,  1.,  0.,  0.,  0.,  1.,  1.,  1.,  1.,  1.,  0.,  1.,
            1.,  1.,  1.,  0.,  0.,  0.,  0.,  1., nan,  0.,  0.,  1.,  0.,
            0.,  1.,  0.,  1., nan,  1.,  0.,  0.,  1.,  1.,  1.,  0.,  0.,
            0.,  0.,  0., nan,  0.,  0.,  1.,  0.,  0.,  1.,  0.,  1.,  1.,
            1.,  0.,  1.,  1.,  0.,  0., nan,  1.,  1.,  0.,  1.,  0.,  0.,
            1.,  0.,  1.,  1., nan,  0.,  0.,  0., nan, nan,  0.,  0.,  0.,
            0.,  0.,  0.,  1.,  0.,  0.,  1.,  0., nan,  0.,  1., nan,  1.,
            0.,  0.,  0.,  0.,  0.,  1., nan,  1.,  0.,  0.,  1.,  0.,  0.,
            1.,  0.,  0.,  0.,  1.,  0.,  1.,  1.,  1.,  0.,  0.,  1.,  0.,
            1.,  1., nan,  1.,  1.,  1.,  1.,  1.,  0.,  1.,  1.,  1.,  1.,
            1.,  0.,  1.,  1., nan,  1.,  0.,  0.,  1.,  1.,  1.,  1.,  1.,
            0.,  0.,  1.,  0.,  0.,  1., nan,  0.,  1.,  1.,  1.,  0.,  1.,
            0.,  1.,  0.,  0.,  1.,  1.,  1.,  0.,  0.,  0.,  0.,  1.,  1.,
            1.,  1.,  1.,  0.,  0.,  1.,  0.,  1.,  0.,  0.,  1.,  0.,  0.,
            0.,  1.,  1.,  1.,  1.,  1.,  1.,  1.,  0.,  0.,  1.,  0.,  1.,
            0.,  0.,  1.,  1.,  0., nan,  1.,  1.,  0.,  1.,  1.,  1.,  1.,
            1.,  1.,  0.,  0.,  1.,  1.,  1.,  0.,  1.,  1.,  1.,  1.,  1.,
            1.,  0.,  0.,  1., nan,  1., nan,  1., nan,  0.,  1.,  1., nan,
            1.,  1.,  1.,  0.,  0.,  0.,  0.,  0.,  0.,  1.,  1.,  0.,  1.,
           nan,  1.,  1.,  1.,  0.,  1.,  0.,  1.,  1.,  0.,  1.,  0.,  0.,
            1.,  0.,  1.,  1.,  0.,  1.,  1.,  1.,  1.,  1.,  1.])

```python
pred.shape
```

    (596,)

```python
hs300 = np.exp(test_set['Close0'])
hs300
```

    date
    2018-08-08    3314.51
    2018-08-09    3397.53
    2018-08-10    3405.02
    2018-08-13    3390.34
    2018-08-14    3372.91
                   ...
    2021-01-13    5577.97
    2021-01-14    5470.46
    2021-01-15    5458.08
    2021-01-18    5518.52
    2021-01-19    5437.52
    Name: Close0, Length: 596, dtype: float64

```python
pred = 2 * pred-1
rtn_temp = 1.0
cum_rtn = []
cum_rtn.append(rtn_temp)
for i in range(pred.shape[0]-1):
    if pred[i] == 1: #  or pred[i] == -1
        rtn_temp = rtn_temp * (1.0 + ((hs300[i+1]-hs300[i]) / hs300[i]) * pred[i])
    else:
        rtn_temp = rtn_temp
    cum_rtn.append(rtn_temp)
```

```python
cum_rtn = np.array(cum_rtn)
cum_rtn
```

    array([1.        , 1.        , 1.00220454, 1.00220454, 0.99705213,
           0.99705213, 0.99243332, 0.99243332, 0.99243332, 0.99243332,
           0.99243332, 0.99243332, 0.99401761, 1.01830211, 1.01830211,
           1.01830211, 1.01830211, 1.01830211, 1.01830211, 1.01830211,
           1.01830211, 1.01830211, 1.01830211, 1.01830211, 1.01645471,
           1.00945916, 1.00945916, 1.00945916, 0.99788588, 0.99788588,
           0.99788588, 0.99788588, 0.99788588, 0.9889062 , 0.9889062 ,
           0.98495606, 0.99516275, 0.95234499, 0.95234499, 0.95029186,
           0.95029186, 0.96447273, 0.95100364, 0.95100364, 0.95630306,
           0.95630306, 0.95630306, 0.95630306, 0.93090902, 0.93230388,
           0.93230388, 0.92627105, 0.89803322, 0.89803322, 0.89803322,
           0.90464214, 0.90464214, 0.89710586, 0.89169217, 0.88585231,
           0.88585231, 0.88585231, 0.89639604, 0.89639604, 0.88741375,
           0.89777772, 0.90201412, 0.90201412, 0.90201412, 0.90201412,
           0.90201412, 0.88210456, 0.88147598, 0.88035353, 0.88035353,
           0.88035353, 0.88035353, 0.90484379, 0.90484379, 0.90049362,
           0.88101892, 0.88098846, 0.87079837, 0.87496856, 0.87795636,
           0.87795636, 0.86329144, 0.8620071 , 0.8620071 , 0.8620071 ,
           0.85539521, 0.84479278, 0.84479278, 0.84479278, 0.84479278,
           0.84479278, 0.84479278, 0.84479278, 0.84479278, 0.86503186,
           0.86503186, 0.86316262, 0.87188006, 0.87188006, 0.87188006,
           0.87188006, 0.87188006, 0.87206403, 0.87206403, 0.87206403,
           0.87206403, 0.87206403, 0.87206403, 0.87206403, 0.87206403,
           0.87187507, 0.87466559, 0.86768518, 0.87676328, 0.87676328,
           0.87676328, 0.87676328, 0.87676328, 0.87808215, 0.87808215,
           0.9062338 , 0.9062338 , 0.90947975, 0.90947975, 0.92992958,
           0.92992958, 0.92992958, 0.92992958, 0.92764924, 0.92764924,
           0.92764924, 0.92764924, 0.9354477 , 0.9354477 , 0.9354477 ,
           0.9354477 , 0.9354477 , 0.92768583, 0.92768583, 0.93935185,
           0.96612777, 0.96166553, 0.96203676, 0.96203676, 0.96126199,
           0.96126199, 0.96126199, 0.96126199, 0.95741272, 0.99437495,
           1.02046216, 1.01978424, 1.03284711, 1.03284711, 1.03157583,
           1.03157583, 1.03157583, 1.00928984, 1.00702766, 1.00702766,
           1.00702766, 1.00738504, 1.00738504, 1.00738504, 0.98415994,
           0.98415994, 0.98687317, 0.98687317, 0.97371677, 0.97648574,
           0.97648574, 0.91944437, 0.91944437, 0.90629522, 0.88955051,
           0.88955051, 0.87483297, 0.86921016, 0.86921016, 0.86921016,
           0.84710821, 0.84710821, 0.85857926, 0.85450504, 0.85450504,
           0.85687736, 0.86719877, 0.86719877, 0.86522693, 0.86522693,
           0.86522693, 0.86575611, 0.86575611, 0.8654265 , 0.85762657,
           0.86870815, 0.8948218 , 0.88804197, 0.8866682 , 0.8866682 ,
           0.8866682 , 0.8866682 , 0.8866682 , 0.91353115, 0.91482442,
           0.91657345, 0.91657345, 0.91657345, 0.91657345, 0.91657345,
           0.91657345, 0.91657345, 0.90641406, 0.90165795, 0.90633723,
           0.88528978, 0.88304093, 0.88304093, 0.88304093, 0.8885255 ,
           0.8885255 , 0.8885255 , 0.8885255 , 0.8800621 , 0.8800621 ,
           0.8800621 , 0.8800621 , 0.88700988, 0.88700988, 0.88873734,
           0.88774693, 0.88774693, 0.87972805, 0.87972805, 0.87972805,
           0.87972805, 0.87030775, 0.87030775, 0.88180954, 0.87321565,
           0.87321565, 0.86534299, 0.86534299, 0.86534299, 0.86534299,
           0.86534299, 0.86534299, 0.86534299, 0.86803163, 0.87428986,
           0.87428986, 0.88613925, 0.88613925, 0.88325193, 0.88544247,
           0.88544247, 0.88544247, 0.88544247, 0.89440171, 0.89968566,
           0.90525442, 0.90525442, 0.90525442, 0.91499314, 0.91499314,
           0.91499314, 0.91942794, 0.92279049, 0.92544055, 0.92544055,
           0.92544055, 0.92544055, 0.91830666, 0.92105837, 0.91194497,
           0.91194497, 0.91194497, 0.91939573, 0.92819665, 0.92819665,
           0.9242075 , 0.9242075 , 0.9242075 , 0.9242075 , 0.9242075 ,
           0.9242075 , 0.91832427, 0.91832427, 0.9245213 , 0.93158903,
           0.93158903, 0.93158903, 0.93158903, 0.93158903, 0.93158903,
           0.93158903, 0.92741612, 0.92904525, 0.92465357, 0.92465357,
           0.92482177, 0.92482177, 0.92621613, 0.91939375, 0.926707  ,
           0.926707  , 0.926707  , 0.92237683, 0.91298375, 0.91298375,
           0.91614771, 0.91614771, 0.91614771, 0.91614771, 0.91614771,
           0.91973725, 0.91973725, 0.91973725, 0.92519731, 0.92355195,
           0.92472077, 0.92528266, 0.92250166, 0.94080461, 0.94080461,
           0.94080461, 0.94080461, 0.93949119, 0.93718162, 0.92548216,
           0.93151502, 0.93102745, 0.93102745, 0.93011168, 0.94389444,
           0.94735169, 0.9602233 , 0.9602233 , 0.9602233 , 0.9602233 ,
           0.9602233 , 0.97237693, 0.97237693, 0.97237693, 0.97237693,
           0.96700203, 0.96700203, 0.96700203, 0.97421233, 0.97421233,
           0.97838451, 0.97838451, 0.90127982, 0.90127982, 0.90127982,
           0.91805289, 0.91807408, 0.92187362, 0.92187362, 0.92187362,
           0.92187362, 0.92187362, 0.92187362, 0.92187362, 0.92187362,
           0.92187362, 0.92294793, 0.92294793, 0.92294793, 0.9115718 ,
           0.9115718 , 0.87925189, 0.90817757, 0.91301786, 0.91301786,
           0.93335916, 0.918223  , 0.918223  , 0.918223  , 0.918223  ,
           0.90055342, 0.8878802 , 0.8878802 , 0.88355493, 0.88355493,
           0.88355493, 0.89934233, 0.89934233, 0.92349251, 0.9483076 ,
           0.9483076 , 0.9483076 , 0.9483076 , 0.9483076 , 0.9483076 ,
           0.9483076 , 0.9483076 , 0.9483076 , 0.9483076 , 0.9483076 ,
           0.9483076 , 0.9483076 , 0.96661046, 0.96661046, 0.96661046,
           0.97604427, 0.97604427, 0.97604427, 0.97604427, 0.97359613,
           0.97359613, 0.98021161, 0.98021161, 0.98021161, 0.98021161,
           0.98021161, 0.98021161, 0.98988414, 0.98988414, 0.98989914,
           0.98989914, 0.98989914, 0.98677199, 0.98677199, 0.98677199,
           0.98152666, 0.98152666, 0.98152666, 0.98152666, 0.99266371,
           0.99266371, 0.9955083 , 0.99819026, 1.02511828, 1.02511828,
           1.02511828, 1.02474258, 1.02474258, 1.03004396, 1.03646709,
           1.03646709, 1.02522164, 1.02706895, 1.01473051, 1.03001693,
           1.03079177, 1.03079177, 1.04463887, 1.04549013, 1.05052127,
           1.05490504, 1.04744499, 1.04744499, 1.06852993, 1.09068144,
           1.09068144, 1.15249807, 1.15249807, 1.15249807, 1.16861711,
           1.14745981, 1.17155991, 1.16038981, 1.14536919, 1.14536919,
           1.14536919, 1.17954352, 1.17954352, 1.17954352, 1.17904062,
           1.17904062, 1.17904062, 1.18940567, 1.21824087, 1.21228897,
           1.21228897, 1.23197974, 1.23197974, 1.23231767, 1.23231767,
           1.23231767, 1.23675178, 1.22547282, 1.21653655, 1.21653655,
           1.21653655, 1.21653655, 1.21653655, 1.19831666, 1.18276353,
           1.19279609, 1.20215123, 1.20369314, 1.20369314, 1.20369314,
           1.23242089, 1.23242089, 1.23904843, 1.23904843, 1.23904843,
           1.22699002, 1.22699002, 1.22699002, 1.22699002, 1.2262915 ,
           1.23841529, 1.24477694, 1.25479447, 1.24646571, 1.23986854,
           1.26780413, 1.26780413, 1.26780413, 1.27233576, 1.27233576,
           1.27427365, 1.27427365, 1.27427365, 1.2730526 , 1.29906645,
           1.29906645, 1.29906645, 1.29044932, 1.28820511, 1.28820511,
           1.27847571, 1.28868633, 1.28851427, 1.28452197, 1.26852856,
           1.26120261, 1.26120261, 1.26120261, 1.2706937 , 1.25003693,
           1.25682579, 1.25682579, 1.26632257, 1.28511881, 1.28527929,
           1.31043653, 1.30321004, 1.29032494, 1.29032494, 1.29032494,
           1.3028965 , 1.3028965 , 1.30206602, 1.30206602, 1.30610856,
           1.30610856, 1.30610856, 1.28941162, 1.29174588, 1.29174588,
           1.28642409, 1.31413527, 1.31414565, 1.31414565, 1.31414565,
           1.31414565, 1.31414565, 1.31414565, 1.31414565, 1.30060924,
           1.3126348 , 1.3126348 , 1.31496273, 1.31496273, 1.31037377,
           1.32265729, 1.30114868, 1.30114868, 1.29930368, 1.29930368,
           1.30507606, 1.29954334, 1.29954334, 1.32434127, 1.32434127,
           1.32434127, 1.33647089, 1.33647089, 1.33205207, 1.31889742,
           1.31889742, 1.31456579, 1.2892288 , 1.28631119, 1.30055514,
           1.28146579])

```python
time = test_set.index
time
```

    Index(['2018-08-08', '2018-08-09', '2018-08-10', '2018-08-13', '2018-08-14',
           '2018-08-15', '2018-08-16', '2018-08-17', '2018-08-20', '2018-08-21',
           ...
           '2021-01-06', '2021-01-07', '2021-01-08', '2021-01-11', '2021-01-12',
           '2021-01-13', '2021-01-14', '2021-01-15', '2021-01-18', '2021-01-19'],
          dtype='object', name='date', length=596)

```python
fontTNR = 'Times New Roman'
plt.figure(figsize=(20,8))
plt.plot(time,cum_rtn,color='black')
plt.xticks(test_set.index[::20])   # 这里的20是指隔20个间隔再画
plt.grid()

plt.title('Backtesting Curve',fontsize = 15 , fontproperties = fontTNR)
plt.xlabel('Time',fontsize = 20 ,fontproperties = fontTNR)
plt.ylabel('Cumulative Return',fontsize = 20 ,fontproperties = fontTNR)

plt.xticks(fontsize = 15 , fontproperties = fontTNR,rotation=25)
plt.yticks(fontsize = 15 , fontproperties = fontTNR)
plt.show()
```

```python
DNN_Model.state_dict()
```

    OrderedDict([('FC_layer1.weight',
                  tensor([[-0.0861, -0.5635, -0.5108,  ...,  0.2102, -0.1364, -0.0351],
                          [ 0.3539,  0.0451, -0.6862,  ...,  0.1420,  0.3328,  0.3169],
                          [-0.0257, -0.1801,  0.1551,  ...,  0.1295, -0.0307,  0.3293],
                          ...,
                          [-0.6684, -0.7623, -0.8492,  ..., -0.4728, -0.2793, -0.3192],
                          [-0.0980,  0.4759,  0.2353,  ..., -0.3693, -0.1182, -0.0647],
                          [-0.3859,  0.1895, -0.0720,  ..., -0.2732, -0.2560, -0.2556]])),
                 ('FC_layer1.bias',
                  tensor([ 0.1029, -0.0978,  0.0527,  0.1733, -0.1503, -0.2079,  0.0588, -0.1384,
                           0.0311, -0.1918, -0.0311, -0.1319, -0.1119, -0.0931, -0.0207, -0.1940,
                           0.0717,  0.0722, -0.1249,  0.0102,  0.1022, -0.1759, -0.2364, -0.0517,
                          -0.0139,  0.0080,  0.0323,  0.1461,  0.0820, -0.1322,  0.1227, -0.0949,
                           0.0391,  0.1717, -0.2085, -0.1996,  0.2035, -0.0375, -0.1390,  0.0097,
                           0.0895,  0.1946, -0.1485,  0.1287,  0.0374,  0.0834, -0.0059, -0.0691])),
                 ('FC_layer2.weight',
                  tensor([[-0.2359,  0.4644, -0.4710,  ...,  0.1371,  0.0869,  0.1297],
                          [ 0.1311, -0.2098, -0.0183,  ..., -0.2080,  0.0376, -0.2414],
                          [-0.0874, -0.2564, -0.1380,  ...,  0.0240,  0.0213, -0.1071],
                          ...,
                          [-0.0534, -0.0920, -0.1771,  ..., -0.1108, -0.0409, -0.0428],
                          [-0.0476, -0.1462, -0.2311,  ..., -0.0941, -0.1929, -0.1422],
                          [ 0.0466,  0.0469, -0.1201,  ..., -0.1148,  0.0119,  0.0596]])),
                 ('FC_layer2.bias',
                  tensor([ 0.0140, -0.0252, -0.1434,  0.1166,  0.2894,  0.0356, -0.0140,  0.0937,
                          -0.0209,  0.0754, -0.1831, -0.0963, -0.1933, -0.0041, -0.0215,  0.0584,
                          -0.1314,  0.2693, -0.1370,  0.0254, -0.2048, -0.0788, -0.0190, -0.0352,
                           0.0127, -0.1445, -0.1950,  0.1544, -0.0668,  0.0474, -0.1389, -0.3142,
                           0.1560, -0.0246, -0.1696, -0.0040])),
                 ('FC_layer3.weight',
                  tensor([[-1.5763e-01,  1.8868e-02, -1.5444e-01, -1.6050e-02, -8.5780e-02,
                            4.8827e-02,  1.7089e-01, -5.0028e-02, -1.8344e-01, -1.2989e-01,
                           -1.5731e-02,  1.3388e-01, -1.9808e-02,  1.7498e-01, -1.9790e-01,
                           -9.7508e-02, -1.9234e-01,  2.0517e-01, -1.9292e-01, -8.1862e-02,
                           -1.9776e-01, -8.2192e-02, -5.8181e-02,  1.3059e-01,  6.8316e-03,
                           -3.0491e-02, -1.7550e-01, -7.1686e-02,  4.6621e-02, -1.6485e-01,
                           -9.9171e-02, -2.2526e-01, -5.9426e-02, -1.3636e-01, -1.3918e-01,
                            7.2536e-02],
                          [-4.0250e-01,  1.6652e-01,  1.2620e-01,  3.1609e-01,  3.2940e-01,
                            1.6882e-01,  1.7309e-01,  8.1675e-02,  1.5435e-02,  3.9453e-02,
                           -3.2551e-01,  1.4842e-01,  8.7654e-02,  2.6551e-01, -3.4158e-01,
                           -2.0640e-01, -3.4906e-01,  4.2143e-01, -5.6415e-02, -1.1820e-01,
                           -3.0409e-01, -4.5581e-02, -7.7152e-02,  1.7091e-01, -1.6446e-02,
                            2.6684e-02, -3.6083e-01,  3.0810e-01, -3.5481e-01, -3.6783e-02,
                           -1.4129e-02, -5.4736e-01,  3.6685e-01,  4.5680e-02, -9.9722e-02,
                           -4.4551e-02],
                          [-4.0733e-02,  6.4404e-02,  2.2875e-02,  3.3654e-01,  3.8175e-02,
                           -1.6680e-02,  3.3439e-01, -3.8119e-03, -1.1310e-01, -4.0748e-02,
                           -2.8271e-01,  2.2232e-04,  6.1828e-02,  2.2192e-01, -2.7651e-01,
                           -1.3772e-01, -2.7409e-01,  1.7964e-01, -2.5535e-01, -1.0441e-01,
                           -1.1541e-01,  2.5392e-02,  8.5710e-02, -5.9037e-02, -3.1696e-02,
                           -1.6340e-01, -2.5830e-01,  9.4642e-02, -3.2512e-01, -1.9128e-02,
                            7.2878e-02, -3.8466e-01,  4.2642e-01,  1.4116e-02, -6.4068e-02,
                            1.0759e-01],
                          [-1.0792e-01, -6.4718e-02,  2.9305e-02,  4.5725e-02, -8.7402e-02,
                            1.7677e-01, -1.1388e-01, -1.5855e-01, -5.2758e-03, -1.0293e-02,
                           -1.5989e-01, -4.7772e-02, -3.6837e-03,  1.3837e-01, -1.3800e-01,
                            9.1490e-02, -1.4130e-01,  1.1627e-01, -1.7613e-01, -1.4890e-01,
                           -1.1985e-01, -6.1589e-02, -1.5684e-01,  7.8940e-02, -1.9377e-01,
                            6.4707e-02, -6.6567e-02,  1.6677e-01, -1.7708e-01, -1.3520e-01,
                           -9.7980e-02, -2.4255e-01,  2.4082e-01, -6.5259e-02, -4.9521e-02,
                           -1.8615e-02],
                          [ 2.5957e-01, -7.5980e-02,  9.6908e-03, -2.4372e-01, -4.8096e-01,
                           -2.4781e-01, -2.2816e-01, -1.3493e-02, -9.3710e-02, -1.4484e-01,
                            2.4468e-01,  6.8252e-02,  3.5550e-02, -2.3865e-01,  3.4078e-01,
                            5.4542e-02,  2.6003e-01, -4.2743e-01,  1.9571e-01, -2.1898e-01,
                            3.6585e-01, -1.3748e-01, -2.3727e-01, -1.4570e-01, -3.0610e-02,
                            1.5240e-02,  3.6015e-01, -8.9189e-02,  1.4875e-01,  3.0533e-02,
                            3.0456e-03,  4.5884e-01, -6.1494e-01,  2.7697e-02,  2.0080e-02,
                            1.6710e-03],
                          [-2.4429e-01,  1.2640e-01,  1.3220e-01,  2.2486e-01,  1.5426e-01,
                            1.5394e-01,  2.7562e-01,  1.4497e-02, -2.6055e-02,  1.2952e-03,
                           -3.0473e-01, -4.2380e-02, -4.5484e-03,  1.4820e-01, -2.7164e-01,
                            5.3840e-02, -1.9368e-01,  4.2370e-01, -5.8003e-02, -6.1301e-02,
                           -3.3806e-01,  6.2851e-02,  1.3354e-01,  1.7504e-01,  2.8834e-02,
                           -1.5985e-01, -3.7975e-01,  3.0278e-02, -3.6712e-01,  5.4724e-02,
                            3.7224e-02, -3.1202e-01,  4.9635e-01, -1.1616e-01,  7.0275e-02,
                            6.0680e-03],
                          [-2.4788e-01,  1.3572e-01,  1.3666e-01,  1.8277e-01,  1.7210e-01,
                            1.1230e-01,  4.3597e-01, -2.1358e-03, -6.0739e-02, -5.7898e-02,
                           -3.6411e-01, -5.8389e-03,  7.0215e-02,  2.1818e-01, -2.8247e-01,
                            1.0756e-01, -1.4074e-01,  5.8754e-01, -2.6964e-01,  2.0395e-01,
                           -3.2725e-01, -1.7093e-02,  6.9262e-02,  1.0324e-01, -6.2924e-02,
                           -9.9214e-02, -4.3801e-01,  2.3702e-01, -3.7086e-01,  5.7940e-02,
                           -1.2366e-01, -3.6793e-01,  6.0831e-01, -5.7057e-02, -1.0810e-01,
                           -2.0857e-01],
                          [-2.4936e-01,  1.1129e-01, -8.5846e-02,  1.1629e-01,  2.3204e-01,
                           -8.3728e-02, -5.0009e-03, -3.6876e-02, -5.6730e-02,  8.9288e-02,
                           -3.0675e-01, -2.0990e-02,  2.0179e-03,  1.3768e-01, -8.8847e-02,
                           -1.2821e-01, -2.4594e-01,  2.9177e-02,  1.1291e-02, -7.5023e-03,
                           -1.9662e-01, -1.1896e-01,  8.1231e-02,  9.6271e-02, -2.1776e-01,
                            4.3825e-02, -1.1745e-01,  1.5375e-01, -2.7449e-01,  8.7305e-02,
                           -6.9382e-02, -2.9008e-01,  3.5329e-02,  3.8964e-02,  1.5343e-01,
                            6.9381e-02],
                          [ 5.0705e-01,  7.5225e-02, -1.9947e-01, -7.2118e-01, -7.1222e-01,
                           -4.6810e-01, -6.6338e-01, -2.6533e-01,  9.3366e-03,  1.5560e-01,
                            6.0585e-01,  2.8834e-02,  8.7921e-02, -1.2617e-01,  3.7753e-01,
                            1.7388e-01,  3.9981e-01, -8.5104e-01,  2.9579e-01, -3.6954e-02,
                            3.4440e-01, -1.4266e-01, -2.7917e-01, -2.8903e-01,  2.2271e-01,
                            2.7432e-01,  7.6578e-01, -3.1120e-01,  5.8330e-01, -2.0584e-01,
                           -1.1826e-01,  8.7565e-01, -8.4367e-01, -1.4038e-01, -2.1993e-01,
                            1.6820e-01],
                          [ 6.1618e-01, -2.0181e-01, -1.1586e-01, -6.5962e-01, -7.5546e-01,
                           -2.4145e-01, -7.1842e-01, -3.0258e-01,  1.8481e-01, -3.1264e-02,
                            7.1100e-01, -2.0891e-01, -9.7056e-02, -3.6655e-01,  3.9227e-01,
                            1.1348e-01,  4.8274e-01, -1.0601e+00,  6.0539e-01, -2.4429e-01,
                            7.6612e-01, -1.0369e-02, -1.8387e-01, -3.5977e-01,  1.6472e-01,
                            2.1449e-01,  9.6197e-01, -2.1844e-01,  5.0461e-01, -1.2234e-01,
                            6.7183e-02,  9.8275e-01, -1.0813e+00,  6.9863e-02, -2.2164e-01,
                            9.3208e-02],
                          [-5.7226e-01,  1.8769e-01, -5.3923e-02,  7.7387e-01,  7.7540e-01,
                            3.4125e-01,  5.3061e-01,  2.2552e-01, -1.8166e-01,  5.1604e-02,
                           -6.1244e-01,  2.0704e-01,  5.5774e-02,  3.6524e-01, -2.9256e-01,
                           -1.9852e-01, -5.6431e-01,  9.7928e-01, -5.5009e-01,  2.2640e-01,
                           -4.6449e-01,  1.4530e-01,  1.9968e-01,  3.0306e-01, -2.6307e-01,
                           -1.7454e-01, -7.3779e-01,  3.9801e-01, -6.5023e-01,  4.2400e-02,
                            1.5837e-01, -9.8155e-01,  8.9757e-01,  3.9165e-02,  2.0116e-01,
                           -2.7800e-01],
                          [ 6.4124e-01, -2.9317e-01, -2.5212e-01, -1.0591e+00, -8.2375e-01,
                           -5.8117e-01, -9.2188e-01, -1.4222e-01,  4.4446e-02,  1.3393e-01,
                            1.0480e+00, -2.2451e-01, -7.7949e-02, -5.0875e-01,  6.1654e-01,
                            1.5854e-01,  4.8515e-01, -1.3993e+00,  4.7638e-01, -2.7428e-01,
                            9.0608e-01, -1.0175e-01, -2.6520e-01, -2.0782e-01,  3.1496e-01,
                            1.1251e-01,  1.1635e+00, -3.7749e-01,  8.8009e-01, -1.9646e-01,
                            5.0011e-02,  1.3022e+00, -1.2342e+00, -9.8339e-02, -1.1810e-01,
                            2.1539e-01],
                          [ 7.1685e-03, -1.2686e-01, -1.1366e-01,  5.2048e-02,  8.9431e-02,
                            1.3545e-01, -3.1158e-02, -4.1021e-02, -5.7851e-02, -1.8050e-01,
                           -1.5466e-02, -1.6666e-01,  1.2606e-01, -7.7843e-02, -2.1250e-01,
                           -1.3819e-01, -8.1280e-02,  1.5420e-01, -2.6689e-01,  5.2791e-02,
                           -1.0808e-01, -1.3916e-01,  6.3449e-02, -5.7353e-03, -6.5060e-02,
                            1.8268e-02, -9.4458e-02,  3.9187e-02, -1.6682e-01,  3.6127e-02,
                           -3.4982e-03, -3.2648e-01,  2.2889e-01,  7.3718e-02,  9.1869e-02,
                           -2.3548e-02],
                          [-5.1995e-02,  9.5385e-02, -1.2733e-01,  3.0907e-01,  1.8886e-01,
                            1.3072e-01,  4.0072e-02, -4.8568e-02, -3.5790e-02, -9.3972e-02,
                           -1.7419e-01, -9.5049e-02, -8.9847e-02, -7.3447e-02, -3.1358e-01,
                           -1.7438e-01, -1.5253e-01,  3.3339e-01, -4.8277e-02, -8.9651e-02,
                           -3.3702e-01,  3.4778e-02,  1.0201e-02, -3.6210e-02, -8.2409e-02,
                           -7.3123e-02, -3.3187e-01,  4.4632e-02, -7.6358e-02,  4.2277e-02,
                            2.2176e-02, -2.3865e-01,  3.6393e-01,  8.5710e-03,  1.7082e-01,
                           -1.0595e-01],
                          [ 9.8232e-02,  5.8383e-02,  1.2162e-02, -1.7030e-01, -1.9584e-01,
                           -2.0903e-03, -3.4812e-02, -1.7809e-01, -2.7124e-02, -1.9780e-01,
                           -8.0016e-03,  1.9516e-02, -3.0012e-02,  8.5232e-02, -1.2433e-01,
                           -7.3589e-02,  1.0981e-01, -2.0920e-01, -7.4301e-02,  5.8491e-02,
                            1.2996e-01,  1.0762e-01, -5.5863e-02, -1.8387e-01, -1.9297e-01,
                            1.0802e-01, -2.3705e-02, -6.5813e-02,  2.9840e-02, -1.8421e-01,
                           -2.5832e-02,  1.0185e-01, -2.0740e-02,  1.0743e-01,  1.5129e-03,
                           -8.9038e-02],
                          [-5.0179e-01,  3.3886e-02, -7.9031e-02,  4.5581e-01,  4.0854e-01,
                            3.0781e-01,  5.2242e-01,  3.1661e-01, -5.0472e-02,  1.7067e-01,
                           -5.6787e-01, -8.0417e-02,  1.3836e-01,  1.4746e-01, -1.9306e-01,
                           -1.2671e-01, -2.6568e-01,  8.4973e-01, -3.4238e-01,  1.6674e-01,
                           -5.3509e-01,  8.3736e-02,  2.0266e-01,  1.8251e-01,  4.1420e-02,
                           -2.3186e-02, -6.4609e-01,  3.0461e-01, -5.0640e-01, -8.1449e-02,
                            1.4625e-02, -7.1546e-01,  8.5928e-01, -6.4718e-02,  2.4350e-01,
                            7.5128e-03],
                          [-2.2285e-01,  1.0857e-02, -1.8248e-01, -3.0123e-02,  1.0723e-01,
                           -1.3167e-01,  3.3189e-02, -8.3115e-02, -1.7852e-01,  7.7904e-02,
                           -1.9266e-01, -8.3915e-02,  3.2321e-02, -3.3958e-02, -1.8725e-01,
                           -1.1478e-01,  5.6716e-02, -6.9924e-02, -2.1040e-01,  1.0919e-01,
                           -2.2569e-01, -1.8240e-01, -1.5931e-02, -1.3928e-01, -7.4190e-02,
                            4.7199e-02, -3.2381e-02, -1.2039e-01, -2.4302e-01, -9.6816e-02,
                            3.3323e-02, -1.8928e-01,  1.9644e-01,  1.3776e-01, -5.1122e-02,
                            1.0238e-02],
                          [ 3.1542e-01, -1.0071e-01, -3.3809e-02, -3.1980e-01, -1.4546e-01,
                           -6.3505e-02, -2.0994e-01, -2.1517e-01, -6.4286e-02,  8.2350e-02,
                            2.7637e-01, -1.6297e-01, -7.3031e-03, -2.0101e-01,  6.0403e-02,
                           -7.4647e-02,  1.1780e-01, -4.6727e-01, -3.2734e-02, -2.2128e-01,
                            2.8653e-01, -1.6685e-01, -1.8050e-01, -2.5443e-01, -8.7459e-02,
                           -6.5968e-03,  4.1845e-01,  3.3995e-02,  2.4856e-01, -1.3881e-02,
                            1.4678e-01,  3.7109e-01, -3.6217e-01,  5.0945e-02, -1.7698e-01,
                           -4.1554e-02],
                          [-8.0044e-01,  6.0991e-02,  2.4030e-01,  1.0383e+00,  1.0808e+00,
                            6.2563e-01,  9.9345e-01,  4.0953e-01,  4.8197e-02, -9.8052e-02,
                           -1.0931e+00, -5.2888e-02,  1.0128e-01,  4.1904e-01, -7.3696e-01,
                           -6.1364e-02, -7.8063e-01,  1.4828e+00, -6.6958e-01,  1.6235e-01,
                           -7.8602e-01,  1.4799e-03,  1.6296e-01,  3.8643e-01, -1.3420e-01,
                           -1.1414e-01, -1.2031e+00,  5.6669e-01, -7.6980e-01,  1.6235e-01,
                            1.2398e-02, -1.4031e+00,  1.3588e+00,  1.0670e-01,  3.1032e-01,
                            1.8600e-02],
                          [-7.5362e-01,  5.5423e-02,  1.7893e-01,  7.6729e-01,  8.0874e-01,
                            5.3784e-01,  5.9990e-01,  2.1773e-01, -9.1679e-02,  1.9330e-02,
                           -8.4539e-01,  1.5457e-01,  1.3157e-01,  3.5714e-01, -4.8129e-01,
                           -1.0837e-01, -5.6057e-01,  1.0813e+00, -5.2564e-01,  1.5808e-01,
                           -7.7431e-01, -3.0707e-02,  8.7690e-02,  4.3069e-01, -3.4133e-02,
                           -1.1733e-01, -8.0619e-01,  4.1244e-01, -7.6783e-01,  2.2284e-01,
                            1.7605e-01, -1.1175e+00,  9.8434e-01,  1.1662e-01,  1.3052e-01,
                            1.7048e-02],
                          [ 5.6157e-01, -2.0774e-01, -2.7389e-01, -5.5774e-01, -8.0048e-01,
                           -4.6774e-01, -7.7437e-01, -1.5247e-01,  9.4347e-02, -1.0681e-01,
                            7.7070e-01, -2.4047e-05,  6.3275e-02, -1.6038e-01,  3.7863e-01,
                            1.7146e-01,  2.7598e-01, -1.0636e+00,  5.1521e-01, -2.3533e-01,
                            5.6459e-01,  1.2233e-01, -5.6879e-02, -2.3444e-01,  2.1186e-02,
                            1.6505e-01,  8.9362e-01, -4.9518e-01,  6.3610e-01, -1.9454e-01,
                           -1.0285e-01,  8.7712e-01, -1.0878e+00,  8.4451e-02, -7.3794e-03,
                            2.3018e-01],
                          [ 5.2103e-01,  9.1095e-02, -1.6315e-01, -5.3979e-01, -5.6779e-01,
                           -2.4636e-01, -6.2370e-01, -1.0021e-01,  7.9842e-02, -4.2564e-02,
                            5.2584e-01,  7.6305e-02, -6.6741e-02, -3.5544e-01,  2.4199e-01,
                           -4.1998e-02,  3.6420e-01, -8.5261e-01,  4.7736e-01, -9.3127e-02,
                            3.7144e-01,  6.1179e-02, -2.0282e-01, -3.1959e-01, -3.3077e-02,
                            1.1341e-01,  7.1937e-01, -1.6487e-01,  5.2345e-01, -1.4580e-01,
                            1.1917e-01,  8.5992e-01, -7.1978e-01, -8.4026e-02, -7.5979e-02,
                            2.1359e-01],
                          [-4.5117e-01, -4.0728e-02,  1.6340e-02,  6.0485e-01,  5.7580e-01,
                            1.3570e-01,  5.0679e-01,  1.4862e-01, -1.0927e-01, -6.9882e-02,
                           -4.3197e-01,  9.0975e-04,  1.6692e-01,  8.4681e-02, -4.5209e-01,
                           -1.8310e-01, -3.6066e-01,  7.6379e-01, -2.7570e-01,  2.2056e-01,
                           -3.9911e-01,  1.4316e-01,  2.3895e-01,  2.4606e-01,  3.6183e-02,
                           -2.8173e-01, -5.7073e-01,  3.0715e-01, -4.4968e-01,  1.9184e-01,
                            8.4140e-02, -5.9109e-01,  4.7188e-01,  1.3540e-01,  3.5808e-02,
                           -5.8094e-02],
                          [ 2.5161e-02,  7.2590e-02, -1.4838e-01, -3.2675e-01, -3.1266e-01,
                           -2.1411e-01, -9.1318e-02, -1.1337e-01, -1.0898e-01, -1.4817e-01,
                            1.9330e-01,  1.0813e-01,  4.8441e-02, -1.0025e-01,  1.0866e-01,
                            5.5700e-02,  1.0385e-01, -3.6523e-01,  2.7763e-01, -2.0037e-01,
                            1.1823e-01,  1.5736e-01, -1.8448e-01,  5.2477e-02,  1.2036e-01,
                            1.3390e-01,  2.3679e-01, -1.6376e-01,  4.2499e-02, -4.8060e-02,
                           -1.2852e-02,  3.2739e-01, -3.4038e-01,  7.8442e-02, -3.8892e-02,
                           -8.5504e-02]])),
                 ('FC_layer3.bias',
                  tensor([-0.1451,  0.0079, -0.0115,  0.0242,  0.1208, -0.1654, -0.0135, -0.1698,
                           0.1641, -0.0451, -0.0242, -0.0379,  0.0152, -0.1718, -0.1689, -0.0997,
                           0.0055,  0.1207, -0.1417, -0.0443,  0.1627, -0.0373, -0.1651, -0.1239])),
                 ('FC_layer4.weight',
                  tensor([[-6.2032e-02, -1.4713e-01, -8.9856e-02,  7.9218e-02, -1.2283e-01,
                           -2.5157e-01, -1.2653e-01, -2.1432e-01, -1.3992e-01, -1.1738e-01,
                           -1.6877e-01, -4.8216e-02,  8.0311e-02,  1.0261e-01, -5.9118e-02,
                            7.0779e-02, -1.3477e-02, -2.6327e-01, -1.7546e-01,  6.8196e-03,
                           -2.3325e-01, -7.9117e-02, -1.0051e-01, -1.0722e-01],
                          [ 2.1639e-01,  3.2000e-01,  5.0037e-01,  3.1543e-01, -5.6504e-01,
                            3.7775e-01,  4.9284e-01,  2.9385e-01, -1.0408e+00, -1.3783e+00,
                            1.1402e+00, -1.6549e+00,  3.1825e-01,  1.7420e-01, -8.8789e-02,
                            9.6651e-01,  2.5790e-01, -2.7491e-01,  1.5444e+00,  1.2605e+00,
                           -1.1991e+00, -9.5089e-01,  7.8119e-01, -5.0550e-01],
                          [ 6.0516e-02,  7.2191e-02,  1.5802e-01,  9.2519e-02, -3.3708e-02,
                            1.2478e-01, -1.6773e-01, -1.9157e-02, -2.4154e-01, -3.6417e-01,
                            1.8787e-01, -1.9966e-01, -7.0878e-02, -2.1687e-01,  3.0925e-02,
                           -3.3352e-02,  2.8121e-02, -3.6361e-01,  4.7108e-02,  2.5743e-01,
                           -3.8639e-01, -4.9703e-02,  2.0170e-01, -4.7837e-02],
                          [ 9.3415e-02,  3.9038e-01,  4.5644e-01,  1.5741e-02, -4.7028e-01,
                            4.5103e-01,  5.4163e-01,  1.3746e-01, -6.6838e-01, -9.9655e-01,
                            5.8240e-01, -1.1682e+00, -4.7298e-02,  2.9966e-01, -2.1743e-01,
                            5.7887e-01,  3.6047e-02, -2.6815e-01,  1.2470e+00,  9.5769e-01,
                           -8.3629e-01, -7.4676e-01,  3.3960e-01, -2.7330e-01],
                          [ 3.0543e-02, -4.8916e-01, -2.0580e-01, -2.7168e-01,  5.3850e-01,
                           -4.9789e-01, -6.1361e-01, -1.6785e-01,  9.1953e-01,  1.1141e+00,
                           -9.3372e-01,  1.4649e+00, -1.7113e-01, -4.0015e-01, -5.8513e-02,
                           -6.3465e-01, -1.6501e-01,  6.0229e-01, -1.6570e+00, -1.2590e+00,
                            1.1666e+00,  9.2976e-01, -7.0111e-01,  3.5051e-01],
                          [ 1.0633e-01, -2.8454e-01, -2.8118e-01, -2.0132e-01, -5.5819e-02,
                           -7.8870e-02,  1.9714e-02, -4.2597e-02,  1.4777e-01,  3.7150e-01,
                           -4.2315e-01,  4.3685e-01,  6.3831e-02,  6.1570e-02, -1.6156e-01,
                           -3.5434e-01, -2.4723e-01,  6.2488e-02, -4.9554e-01, -2.4095e-01,
                            3.3478e-01,  2.1917e-02, -2.4287e-01,  2.9870e-02],
                          [ 5.9556e-02, -1.3503e-01, -2.0922e-02, -8.6814e-02,  4.0498e-02,
                           -9.0152e-02, -2.5226e-01, -2.2193e-01, -2.0231e-01,  2.8868e-02,
                            1.1160e-01, -1.0689e-01, -2.7715e-01,  1.1711e-01, -1.5687e-01,
                           -4.7492e-02, -2.4792e-01, -7.1277e-02,  2.0550e-02,  1.3740e-02,
                           -1.7675e-01, -6.1213e-03,  8.1961e-02, -2.8159e-01],
                          [-2.3162e-01, -1.4717e-01,  5.5652e-02, -1.9490e-01,  8.4206e-03,
                           -2.9278e-01, -5.4586e-02,  9.9816e-03,  2.1621e-01,  5.3825e-01,
                           -2.9789e-01,  7.0983e-01, -2.4044e-02, -5.8823e-02,  4.8796e-02,
                           -2.0613e-01, -9.5606e-03,  7.5029e-02, -7.2448e-01, -5.2746e-01,
                            3.4836e-01,  2.1013e-01, -1.9923e-01, -1.2923e-02],
                          [-2.0249e-02,  3.0672e-01,  2.1209e-01,  8.0248e-02, -4.5953e-01,
                            1.8632e-01,  4.3298e-01,  2.1034e-01, -1.0567e+00, -8.2499e-01,
                            9.4889e-01, -1.0286e+00, -3.8023e-03,  4.1586e-01, -1.8947e-01,
                            7.6165e-01,  3.6232e-02, -3.0432e-01,  1.2662e+00,  9.8726e-01,
                           -9.8945e-01, -9.2847e-01,  8.2791e-01, -3.2166e-01],
                          [-1.6355e-01, -7.1227e-01, -2.1366e-01,  9.5916e-04,  6.9108e-01,
                           -5.4642e-01, -5.5108e-01, -2.3929e-01,  1.2650e+00,  1.2779e+00,
                           -1.2826e+00,  1.6277e+00, -3.4892e-01, -2.9999e-01,  1.8464e-01,
                           -1.0074e+00,  9.4502e-02,  6.4880e-01, -1.7828e+00, -1.3357e+00,
                            1.3621e+00,  8.7730e-01, -8.5667e-01,  3.9720e-01],
                          [ 1.4073e-01,  3.3857e-01,  1.0371e-01,  3.2180e-02, -8.3751e-02,
                            1.6141e-01,  1.1849e-01, -1.2933e-01, -4.7865e-01, -6.3727e-01,
                            3.3267e-01, -7.3078e-01,  2.0280e-02,  2.0269e-01, -1.8950e-01,
                            4.2790e-01,  1.0871e-01, -2.2768e-01,  6.7758e-01,  3.3401e-01,
                           -2.6517e-01, -4.0787e-01,  2.2386e-01, -8.4474e-03],
                          [-1.4583e-01, -4.2622e-01, -4.2170e-01,  4.7281e-02,  5.0980e-01,
                           -2.7019e-01, -4.9610e-01, -2.4811e-01,  6.1358e-01,  7.2919e-01,
                           -8.7790e-01,  1.2400e+00, -8.4429e-02, -1.6614e-01,  1.3565e-01,
                           -4.7334e-01, -1.6465e-01,  2.9387e-01, -1.1166e+00, -8.3574e-01,
                            7.6809e-01,  7.9646e-01, -5.7243e-01,  3.0396e-01]])),
                 ('FC_layer4.bias',
                  tensor([-0.2170, -0.2406, -0.0231,  0.0457,  0.2083,  0.0397, -0.1073, -0.0637,
                          -0.0361,  0.1476,  0.0649,  0.1438])),
                 ('FC_layer5.weight',
                  tensor([[ 0.2527, -2.5937, -0.5486, -1.9344,  2.5169,  0.8707, -0.3714,  0.9929,
                           -2.0736,  2.8293, -1.1125,  1.9031],
                          [ 0.3218,  2.6480,  0.2650,  1.7932, -2.3031, -0.3996, -0.1756, -0.7388,
                            2.0334, -2.7776,  0.8806, -1.6891]])),
                 ('FC_layer5.bias', tensor([-0.0505, -0.0314]))])

```python
optimizer.state_dict()
```

    {'state': {0: {'momentum_buffer': None},
      1: {'momentum_buffer': None},
      2: {'momentum_buffer': None},
      3: {'momentum_buffer': None},
      4: {'momentum_buffer': None},
      5: {'momentum_buffer': None},
      6: {'momentum_buffer': None},
      7: {'momentum_buffer': None},
      8: {'momentum_buffer': None},
      9: {'momentum_buffer': None}},
     'param_groups': [{'lr': 0.04210455402856372,
       'momentum': 0,
       'dampening': 0,
       'weight_decay': 0,
       'nesterov': False,
       'params': [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]}]}

```python

```

```python

```