def get_reward(mean_sample_vote, sound_extended, i_target, speaker, loudness_factor, softmax=False):


    if softmax:
        reward = exp(mean_sample_vote[i_target])
        other_exp = 0.0
        for i in xrange(len(mean_sample_vote)):
            if i!=i_target:
                other_exp += exp(mean_sample_vote[i])
        reward /= reward + other_exp

    else:
        reward = mean_sample_vote[i_target]
        for i in xrange(len(mean_sample_vote)):
            if i!=i_target:
                reward -= mean_sample_vote[i]

        if speaker == 'adult':
            target_loudness = [72.77, 65.20, 66.04, 68.37, 68.47]
        else:
            target_loudness = [73.78, 68.68, 69.78]

        level = float(sound_extended.level)
        if isinf(level):
            level = 0.0
        loudness_reward = level - target_loudness[i_target]

        if loudness_reward > 0.0:
            loudness_reward = 0.0

        reward += loudness_factor * loudness_reward



    return reward
	def get_confidences(self,mean_sample_vote):

		n_classes = len(mean_sample_vote)
		confidences = np.zeros(n_classes)
		norm_sum = 0.0
		for i in xrange(n_classes):
		    confidence_i = exp(mean_sample_vote[i])
		    confidences[i] = confidence_i
		    norm_sum += confidence_i
		confidences /= norm_sum

		return confidences
Example #3
0
def get_confidences(mean_sample_vote):

    n_classes = len(mean_sample_vote)
    confidences = np.zeros(n_classes)
    norm_sum = 0.0
    for i in xrange(n_classes):
        confidence_i = exp(mean_sample_vote[i])
        confidences[i] = confidence_i
        norm_sum += confidence_i
    confidences /= norm_sum

    return confidences
Example #4
0
def get_reward(mean_sample_vote,
               sound_extended,
               i_target,
               speaker,
               loudness_factor,
               softmax=False):

    if softmax:
        reward = exp(mean_sample_vote[i_target])
        other_exp = 0.0
        for i in xrange(len(mean_sample_vote)):
            if i != i_target:
                other_exp += exp(mean_sample_vote[i])
        reward /= reward + other_exp

    else:
        reward = mean_sample_vote[i_target]
        for i in xrange(len(mean_sample_vote)):
            if i != i_target:
                reward -= mean_sample_vote[i]

        if speaker == 'adult':
            target_loudness = [72.77, 65.20, 66.04, 68.37, 68.47]
        else:
            target_loudness = [73.78, 68.68, 69.78]

        level = float(sound_extended.level)
        if isinf(level):
            level = 0.0
        loudness_reward = level - target_loudness[i_target]

        if loudness_reward > 0.0:
            loudness_reward = 0.0

        reward += loudness_factor * loudness_reward

    return reward