target_class_ids = target_class_ids.flatten()
weight = weight.T
weight = weight[target_class_ids, :]
weight = weight.reshape([minibatch_size, -1, input_size])
// For some reason if we select elements from a vector, it will use
// GpuAdvancedIncSubtensor1 and be slow. If bias is a matrix, it will
// use the faster GpuAdvancedIncSubtensor1_dev20.
bias = bias[:, None]
bias = bias[target_class_ids, 0]
// bias = bias[target_class_ids]
bias = bias.reshape([minibatch_size, -1])
result = (layer_input * weight).sum(2) + bias
return result.reshape([num_time_steps, num_sequences, -1])
def _get_target_list_preact(self, layer_input, target_class_ids):
Structures the preactivations for a list of target classes.
After Change
bias = bias[:, None]
bias = bias[target_class_ids, 0]
// bias = bias[target_class_ids]
return (layer_input[:, :, None, :] * weight).sum(3) + bias
def _get_target_list_preact(self, layer_input, target_class_ids):
Structures the preactivations for a list of target classes.