Exemplo n.º 1
0
def inference(x, sequence_len, training, full_sequence_len, configure):
    """Infer a logits of the input signal batch.

    Args:
        x: Tensor of shape [batch_size, max_time,channel], a batch of the input signal with a maximum length `max_time`.
        sequence_len: Tensor of shape [batch_size], given the real lenghs of the segments.
        training: Placeholder of Boolean, Ture if the inference is during training.
        full_sequence_len: Scalar float, the maximum length of the sample in the batch.
        configure:Model configuration.

    Returns:
        logits: Tensor of shape [batch_size, max_time, class_num]
        ratio: Scalar float, the scale factor between the output logits and the input maximum length.
    """
    cnn_feature = getcnnfeature(x,
                                training=training,
                                cnn_config=configure['cnn']['model'])
    feashape = cnn_feature.get_shape().as_list()
    ratio = full_sequence_len / feashape[1]
    if configure['rnn']['layer_num'] == 0:
        logits = getcnnlogit(cnn_feature)
    else:
        logits = rnn_layers(cnn_feature,
                            sequence_len,
                            training,
                            layer_num=configure['rnn']['layer_num'],
                            hidden_num=configure['rnn']['hidden_num'],
                            cell=configure['rnn']['cell_type'])
        #logits = cudnn_rnn(cnn_feature,rnn_layer_num)
    return logits, ratio
Exemplo n.º 2
0
def inference(x, sequence_len, training, full_sequence_len, rnn_layer_num=3):
    """Infer a logits of the input signal batch.

    Args:
        x: Tensor of shape [batch_size, max_time,channel], a batch of the input signal with a maximum length `max_time`.
        sequence_len: Tensor of shape [batch_size], given the real lenghs of the segments.
        training: Placeholder of Boolean, Ture if the inference is during training.
        full_sequence_len: Scalar float, the maximum length of the sample in the batch.
        rnn_layer_num:Scalar Int, default is 3, the number of layer of RNN in the network.

    Returns:
        logits: Tensor of shape [batch_size, max_time, class_num]
        ratio: Scalar float, the scale factor between the output logits and the input maximum length.
    """
    cnn_feature = getcnnfeature(x, training=training)
    feashape = cnn_feature.get_shape().as_list()
    ratio = full_sequence_len / feashape[1]
    if rnn_layer_num == 0:
        logits = getcnnlogit(cnn_feature)
    else:
        logits = rnn_layers(cnn_feature,
                            sequence_len,
                            training,
                            layer_num=rnn_layer_num)
        #logits = cudnn_rnn(cnn_feature,rnn_layer_num)
    return logits, ratio
Exemplo n.º 3
0
def inference(x):
    logits = getcnnlogit(x, outnum=5)
    return logits