def calculate_outputs(self, x):
h = lstm_layer(x, self.history_length, self.lstm_size)
c = wavenet(x, self.dilations, self.filter_widths, self.skip_channels, self.residual_channels)
h = tf.concat([h, c, x], axis=2)
self.h_final = time_distributed_dense_layer(h, 50, activation=tf.nn.relu, scope='dense-1')
y_hat = time_distributed_dense_layer(self.h_final, 1, activation=tf.nn.sigmoid, scope='dense-2')
y_hat = tf.squeeze(y_hat, 2)
final_temporal_idx = tf.stack([tf.range(tf.shape(self.history_length)[0]), self.history_length - 1], axis=1)
self.final_states = tf.gather_nd(self.h_final, final_temporal_idx)
self.final_predictions = tf.gather_nd(y_hat, final_temporal_idx)
self.prediction_tensors = {
'user_ids': self.user_id,
'product_ids': self.product_id,
'final_states': self.final_states,
'predictions': self.final_predictions
}
return y_hat
rnn_product.py 文件源码
python
阅读 26
收藏 0
点赞 0
评论 0
评论列表
文章目录