import tensorflow as tf

            if target_weight_strategy == 'rect':
                avg_neg_log_lhood = tf.reduce_mean(neg_log_lhoods)
            else:
                neg_log_lhoods = tf.multiply(neg_log_lhoods, target_weights)
                # be careful to have at least one weight be nonzero
                # should we be taking the mean elem-wise by batch? i think this is a big bug
                avg_neg_log_lhood = tf.reduce_sum(neg_log_lhoods) / tf.reduce_sum(target_weights)
            neg_log_lhoods_inspect = tf.reshape(neg_log_lhoods, [batch_size, rnn_nunroll])

        # Train op
        if mode == 'train':
            lr = tf.Variable(0.0, trainable=False)
            self._lr = lr
            self._lr_summary = tf.summary.scalar('learning_rate', self._lr)

            tvars = tf.trainable_variables()
            grads = tf.gradients(avg_neg_log_lhood, tvars)
            if grad_clip > 0.0:
                grads, _ = tf.clip_by_global_norm(grads, grad_clip)

            if opt == 'sgd':
                optimizer = tf.train.GradientDescentOptimizer(lr)
            else:
                raise NotImplementedError()

            train_op = optimizer.apply_gradients(zip(grads, tvars), global_step=tf.contrib.framework.get_or_create_global_step())

        # Tensor exports
        self.feats_audio = feats_audio_nunroll
        self.feats_other = feats_other_nunroll
