質問編集履歴
1
codeの追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -25,3 +25,83 @@
|
|
25
25
|
|
26
26
|
|
27
27
|
よろしくお願いします。
|
28
|
+
|
29
|
+
|
30
|
+
|
31
|
+
モデルのコードは以下になります。
|
32
|
+
|
33
|
+
```python
|
34
|
+
|
35
|
+
'モデルA'
|
36
|
+
|
37
|
+
X:input_data
|
38
|
+
|
39
|
+
|
40
|
+
|
41
|
+
lstm_3 = tf.nn.rnn_cell.BasicLSTMCell(20, name='blstmc3')#
|
42
|
+
|
43
|
+
lstm_4 = tf.nn.rnn_cell.BasicLSTMCell(20, name='blstmc4')#
|
44
|
+
|
45
|
+
|
46
|
+
|
47
|
+
lstm_out_3 = tf.nn.dynamic_rnn(lstm_3,X,dtype=tf.float32,time_major=False)#
|
48
|
+
|
49
|
+
lstm_out_4 = tf.nn.dynamic_rnn(lstm_4,lstm_out_3,dtype=tf.float32,time_major=False)#
|
50
|
+
|
51
|
+
|
52
|
+
|
53
|
+
lstm_out_last = lstm_out_4[:,-1,:]##last output only
|
54
|
+
|
55
|
+
|
56
|
+
|
57
|
+
W11 = weight_variable([20, 10])
|
58
|
+
|
59
|
+
b11 = bias_variable([10])
|
60
|
+
|
61
|
+
f_logit = tf.matmul(lstm_out_last, W11) + b11
|
62
|
+
|
63
|
+
predict_vector = tf.nn.relu(f_logit)
|
64
|
+
|
65
|
+
|
66
|
+
|
67
|
+
'モデルB'
|
68
|
+
|
69
|
+
X:input_data
|
70
|
+
|
71
|
+
|
72
|
+
|
73
|
+
lstm_1 = tf.nn.rnn_cell.BasicLSTMCell(10, name='blstmc1')#
|
74
|
+
|
75
|
+
lstm_2 = tf.nn.rnn_cell.BasicLSTMCell(10, name='blstmc2')#
|
76
|
+
|
77
|
+
lstm_3 = tf.nn.rnn_cell.BasicLSTMCell(20, name='blstmc3')#
|
78
|
+
|
79
|
+
lstm_4 = tf.nn.rnn_cell.BasicLSTMCell(20, name='blstmc4')#
|
80
|
+
|
81
|
+
|
82
|
+
|
83
|
+
lstm_out_1 = tf.nn.dynamic_rnn(lstm_1,X,dtype=tf.float32,time_major=False)#
|
84
|
+
|
85
|
+
lstm_out_2 = tf.nn.dynamic_rnn(lstm_2,lstm_out_1,dtype=tf.float32,time_major=False)#
|
86
|
+
|
87
|
+
lstm_out_3 = tf.nn.dynamic_rnn(lstm_3,lstm_out_2,dtype=tf.float32,time_major=False)#
|
88
|
+
|
89
|
+
lstm_out_4 = tf.nn.dynamic_rnn(lstm_4,lstm_out_3,dtype=tf.float32,time_major=False)#
|
90
|
+
|
91
|
+
|
92
|
+
|
93
|
+
lstm_out_last = lstm_out_4[:,-1,:]##last output only
|
94
|
+
|
95
|
+
|
96
|
+
|
97
|
+
W11 = weight_variable([20, 10])
|
98
|
+
|
99
|
+
b11 = bias_variable([10])
|
100
|
+
|
101
|
+
f_logit = tf.matmul(lstm_out_last, W11) + b11
|
102
|
+
|
103
|
+
predict_vector = tf.nn.relu(f_logit)
|
104
|
+
|
105
|
+
|
106
|
+
|
107
|
+
```
|