(raw_input, input_type, max_len, vocab, dtype='int32',
              index_from=2, oov=1)
Transforms the raw received input data to put it in the required
    format for running through neon.
    Args:
        raw_input (blob): input data contents ex. a stream of text
        input_type (str): type for input data file
        max_len (int): max sentence length to deal with
        vocab (dict): vocabulary file
        dtype (type, optional): type for each element of a tensor.  Defaults to
                                float32
    Returns:
        Tensor: neon input data file of appropriate shape.
Transforms the raw received input data to put it in the required
    format for running through neon.
    Args:
        raw_input (blob): input data contents ex. a stream of text
        input_type (str): type for input data file
        max_len (int): max sentence length to deal with
        vocab (dict): vocabulary file
        dtype (type, optional): type for each element of a tensor.  Defaults to
                                float32
    Returns:
        Tensor: neon input data file of appropriate shape.
Transforms the raw received input data to put it in the required format for running through neon . Args : raw_input ( blob ) : input data contents ex . a stream of text input_type ( str ) : type for input data file max_len ( int ) : max sentence length to deal with vocab ( dict ) : vocabulary file dtype ( type optional ) : type for each element of a tensor . Defaults to float32 Returns : Tensor : neon input data file of appropriate shape .
def prep_data(raw_input, input_type, max_len, vocab, dtype='int32',
              index_from=2, oov=1):
    """
    Transforms the raw received input data to put it in the required
    format for running through neon.
    Args:
        raw_input (blob): input data contents ex. a stream of text
        input_type (str): type for input data file
        max_len (int): max sentence length to deal with
        vocab (dict): vocabulary file
        dtype (type, optional): type for each element of a tensor.  Defaults to
                                float32
    Returns:
        Tensor: neon input data file of appropriate shape.
    """
    dtype = np.dtype(dtype)
    if input_type == "text":
        in_shape = (max_len, 1)

        tokens = tokenize(raw_input)
        sent_inp = np.array(
            [oov if t not in vocab else (vocab[t] + index_from) for t in tokens])
        l = min(len(sent_inp), max_len)
        xbuf = np.zeros(in_shape, dtype=dtype)
        xbuf[-l:] = sent_inp[-l:].reshape(-1, 1)

        return xbuf
    else:
        raise ValueError("Unsupported data type: %s" % input_type)
def prep_data ( raw_input , input_type , max_len , vocab , dtype = 'int32' , index_from = 2 , oov = 1 ) : dtype = np . dtype ( dtype ) if input_type == "text" : in_shape = ( max_len , 1 ) tokens = tokenize ( raw_input ) sent_inp = np . array ( [ oov if t not in vocab else ( vocab [ t ] + index_from ) for t in tokens ] ) l = min ( len ( sent_inp ) , max_len ) xbuf = np . zeros ( in_shape , dtype = dtype ) xbuf [ - l : ] = sent_inp [ - l : ] . reshape ( - 1 , 1 ) return xbuf else : raise ValueError ( "Unsupported data type: %s" % input_type )