<commit_before>import theano as t

def loadShared(x, borrow=True, log=None) :
    '''Transfer numpy.array to theano.shared variable.
       NOTE: Shared variables allow for optimized GPU execution
    '''
    import numpy as np
    if log is not None :
        log.debug('Wrap memory into shared variables')
    return t.shared(np.asarray(x, dtype=t.config.floatX), borrow=borrow)

def splitToShared(x, borrow=True, log=None) :
    '''Create shared variables for both the input and expectedOutcome vectors.
       x      : This can be a vector list of inputs and expectedOutputs. It is
                assumed they are of the same length.
                    Format - (data, label)
       borrow : Should the theano vector accept responsibility for the memory
       return : Shared Variable equivalents for these items
                    Format - (data, label)
    '''
    data, label = x
    return (loadShared(data, borrow, log), 
            t.tensor.cast(loadShared(label, borrow, log), 'int32'))<commit_msg>updating shared.py to optionally cast into an integer. Not all cases warrant the cast<commit_after>import theano as t

def loadShared(x, borrow=True, log=None) :
    '''Transfer numpy.array to theano.shared variable.
       NOTE: Shared variables allow for optimized GPU execution
    '''
    import numpy as np
    if log is not None :
        log.debug('Wrap memory into shared variables')
    return t.shared(np.asarray(x, dtype=t.config.floatX), borrow=borrow)

def splitToShared(x, borrow=True, castInt=True, log=None) :
    '''Create shared variables for both the input and expectedOutcome vectors.
       x      : This can be a vector list of inputs and expectedOutputs. It is
                assumed they are of the same length.
                    Format - (data, label)
       borrow : Should the theano vector use the same buffer as numpy
       castInt: Should the label be casted into int32
       return : Shared Variable equivalents for these items
                    Format - (data, label)
    '''
    data, label = x
    data = loadShared(data, borrow, log)
    label = loadShared(label, borrow, log)
    if castInt :
        label = t.tensor.cast(label, 'int32')
    return data, label
{'fraction_non_alphanumeric': 0.07980162308385934, 'fraction_numerical': 0.002705139765554554, 'mean_word_length': 2.6258169934640523, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3817542', 'n_tokens_mistral': 603, 'n_tokens_neox': 585, 'n_words': 244}