コード例 #1
0
 def get_predictions(self, frames, scope):
     frames = self._reshape_to_conv(frames)
     cnn = CNN()
     if self.operation == 'training':
         cnn_output = cnn.create_model(frames,
                                       cnn.conv_filters,
                                       keep_prob=self.keep_prob)
     else:
         cnn_output = cnn.create_model(frames,
                                       cnn.conv_filters,
                                       keep_prob=1.0)
     cnn_output = self._reshape_to_rnn(cnn_output)
     rnn = RNN()
     rnn_output = rnn.create_model(cnn_output, scope + '_rnn')
     if self.is_attention:
         attention = Attention(self.batch_size)
         attention_output = attention.create_model(rnn_output,
                                                   scope + '_attention')
         fc = FC(self.num_classes)
         outputs = fc.create_model(attention_output, scope + '_fc')
     else:
         rnn_output = rnn_output[:, -1, :]
         fc = FC(self.num_classes)
         outputs = fc.create_model(rnn_output, scope + '_fc')
     return outputs
コード例 #2
0
    def get_multi_predictions(self, frames):
        frames = self._reshape_to_conv(frames)
        cnn = CNN()
        if self.operation == 'training':
            cnn_output = cnn.create_model(frames,
                                          cnn.conv_filters,
                                          keep_prob=self.keep_prob)
        else:
            cnn_output = cnn.create_model(frames,
                                          cnn.conv_filters,
                                          keep_prob=1.0)
        cnn_output = self._reshape_to_rnn(cnn_output)
        rnn = RNN()
        arousal_rnn_output = rnn.create_model(cnn_output, 'arousal_rnn')
        valence_rnn_output = rnn.create_model(cnn_output, 'valence_rnn')
        dominance_rnn_output = rnn.create_model(cnn_output, 'dominance_rnn')
        if self.is_attention:
            attention = Attention(self.batch_size)
            arousal_attention_output = attention.create_model(
                arousal_rnn_output, 'arousal_attention')
            valence_attention_output = attention.create_model(
                valence_rnn_output, 'valence_attention')
            dominance_attention_output = attention.create_model(
                dominance_rnn_output, 'dominance_attention')
            fc = FC(self.num_classes)
            arousal_fc_outputs = fc.create_model(arousal_attention_output,
                                                 'arousal_fc')
            valence_fc_outputs = fc.create_model(valence_attention_output,
                                                 'valence_fc')
            dominance_fc_outputs = fc.create_model(dominance_attention_output,
                                                   'dominance_fc')
        else:
            arousal_rnn_output = arousal_rnn_output[:, -1, :]
            valence_rnn_output = valence_rnn_output[:, -1, :]
            dominance_rnn_output = dominance_rnn_output[:, -1, :]
            fc = FC(self.num_classes)
            arousal_fc_outputs = fc.create_model(arousal_rnn_output,
                                                 'arousal_fc')
            valence_fc_outputs = fc.create_model(valence_rnn_output,
                                                 'valence_fc')
            dominance_fc_outputs = fc.create_model(dominance_rnn_output,
                                                   'dominance_fc')

        return arousal_fc_outputs, valence_fc_outputs, dominance_fc_outputs
コード例 #3
0
 def multi_get_attention(self, frames):
     frames = self._reshape_to_conv(frames)
     cnn = CNN()
     cnn_output = cnn.create_model(frames, cnn.conv_filters)
     cnn_output = self._reshape_to_rnn(cnn_output)
     rnn = RNN()
     rnn_output = rnn.create_model(cnn_output)
     if self.is_attention:
         attention = Attention(self.batch_size)
         attention_output = attention.attention_analysis(rnn_output)
         return attention_output
     else:
         rnn_output = rnn_output[:, -1, :]
         fc = FC(self.num_classes)
         outputs = fc.create_model(rnn_output)
         return outputs