src/core/train.py
def train_step(return_var, updates, x_unlabeled, inputs, y_true,
        batch_sizes, x_labeled=None, y_labeled=None,
        batches_per_epoch=100):
    '''
    Performs one training step. Evaluates the tensors in return_var and
    updates, then returns the values of the tensors in return_var.

    return_var:         list of tensors to evaluate and return
    updates:            list of tensors to evaluate only
    x_unlabeled:        unlabeled input data
    inputs:             dictionary containing input_types and
                        input_placeholders as key, value pairs, respectively
    y_true:             true labels placeholder
    batch_sizes:        dictionary containing input_types and batch_sizes as
                        key, value pairs, respectively
    x_labeled:          labeled input data
    y_labeled:          labeled input labels
    batches_per_epoch:  parameter updates per epoch*

    returns:    the evaluated result of all tensors in return_var, summed
                across all epochs

    *note: the term epoch is used loosely here, it does not necessarily
           refer to one iteration over the entire dataset. instead, it
           is just batches_per_epoch parameter updates.
    '''
    x_unlabeled, x_labeled, y_labeled = check_inputs(x_unlabeled, x_labeled, y_labeled, y_true)

    # combine data
    x = np.concatenate((x_unlabeled, x_labeled), 0)

    # get shape of y_true
    y_shape = y_true.get_shape()[1:K.ndim(y_true)].as_list()

    return_vars_ = np.zeros(shape=(len(return_var)))
    # train batches_per_epoch batches
    for batch_num in range(0, batches_per_epoch):
        feed_dict = {K.learning_phase(): 1}

        # feed corresponding input for each input_type
        for input_type, input_placeholder in inputs.items():
            if input_type == 'Labeled':
                if len(x_labeled):
                    batch_ids = np.random.choice(len(x_labeled), size=min(batch_sizes[input_type], len(x_labeled)), replace=False)
                    feed_dict[input_placeholder] = x_labeled[batch_ids]
                    feed_dict[y_true] = y_labeled[batch_ids]
                else:
                    # we have no labeled points, so feed an empty array
                    feed_dict[input_placeholder] = x[0:0]
                    feed_dict[y_true] = np.empty([0] + y_shape)
            elif input_type == 'Unlabeled':
                if len(x_unlabeled):
                    batch_ids = np.random.choice(len(x_unlabeled), size=batch_sizes[input_type], replace=False)
                    feed_dict[input_placeholder] = x_unlabeled[batch_ids]
                else:
                    # we have no unlabeled points, so feed an empty array
                    feed_dict[input_placeholder] = x[0:0]
            elif input_type in ['Orthonorm']:
                batch_ids = np.random.choice(len(x), size=batch_sizes[input_type], replace=False)
                feed_dict[input_placeholder] = x[batch_ids]
            else:
                raise Exception("Unrecognized feed name ['{}']".format(input_type))

        all_vars = return_var + updates
        return_vars_ += np.asarray(K.get_session().run(all_vars, feed_dict=feed_dict)[:len(return_var)])

    return return_vars_

    Performs one training step. Evaluates the tensors in return_var and
    updates, then returns the values of the tensors in return_var.

    return_var:         list of tensors to evaluate and return
    updates:            list of tensors to evaluate only
    x_unlabeled:        unlabeled input data
    inputs:             dictionary containing input_types and
                        input_placeholders as key, value pairs, respectively
    y_true:             true labels placeholder
    batch_sizes:        dictionary containing input_types and batch_sizes as
                        key, value pairs, respectively
    x_labeled:          labeled input data
    y_labeled:          labeled input labels
    batches_per_epoch:  parameter updates per epoch*

    returns:    the evaluated result of all tensors in return_var, summed
                across all epochs

    *note: the term epoch is used loosely here, it does not necessarily
           refer to one iteration over the entire dataset. instead, it
           is just batches_per_epoch parameter updates.
    
Performs one training step. Evaluates the tensors in return_var and
updates, then returns the values of the tensors in return_var.



the evaluated result of all tensors in return_var, summed
across all epochs

the term epoch is used loosely here, it does not necessarily
refer to one iteration over the entire dataset. instead, it
is just batches_per_epoch parameter updates.
Performs one training step . Evaluates the tensors in return_var and updates then returns the values of the tensors in return_var . the evaluated result of all tensors in return_var summed across all epochs the term epoch is used loosely here it does not necessarily refer to one iteration over the entire dataset . instead it is just batches_per_epoch parameter updates .
def train_step(return_var, updates, x_unlabeled, inputs, y_true,
        batch_sizes, x_labeled=None, y_labeled=None,
        batches_per_epoch=100):
    x_unlabeled, x_labeled, y_labeled = check_inputs(x_unlabeled, x_labeled, y_labeled, y_true)
    x = np.concatenate((x_unlabeled, x_labeled), 0)
    y_shape = y_true.get_shape()[1:K.ndim(y_true)].as_list()
    return_vars_ = np.zeros(shape=(len(return_var)))
    for batch_num in range(0, batches_per_epoch):
        feed_dict = {K.learning_phase(): 1}
        for input_type, input_placeholder in inputs.items():
            if input_type == 'Labeled':
                if len(x_labeled):
                    batch_ids = np.random.choice(len(x_labeled), size=min(batch_sizes[input_type], len(x_labeled)), replace=False)
                    feed_dict[input_placeholder] = x_labeled[batch_ids]
                    feed_dict[y_true] = y_labeled[batch_ids]
                else:
                    feed_dict[input_placeholder] = x[0:0]
                    feed_dict[y_true] = np.empty([0] + y_shape)
            elif input_type == 'Unlabeled':
                if len(x_unlabeled):
                    batch_ids = np.random.choice(len(x_unlabeled), size=batch_sizes[input_type], replace=False)
                    feed_dict[input_placeholder] = x_unlabeled[batch_ids]
                else:
                    feed_dict[input_placeholder] = x[0:0]
            elif input_type in ['Orthonorm']:
                batch_ids = np.random.choice(len(x), size=batch_sizes[input_type], replace=False)
                feed_dict[input_placeholder] = x[batch_ids]
            else:
                raise Exception("Unrecognized feed name ['{}']".format(input_type))
        all_vars = return_var + updates
        return_vars_ += np.asarray(K.get_session().run(all_vars, feed_dict=feed_dict)[:len(return_var)])
    return return_vars_
def train_step ( return_var , updates , x_unlabeled , inputs , y_true , batch_sizes , x_labeled = None , y_labeled = None , batches_per_epoch = 100 ) : x_unlabeled , x_labeled , y_labeled = check_inputs ( x_unlabeled , x_labeled , y_labeled , y_true ) x = np . concatenate ( ( x_unlabeled , x_labeled ) , 0 ) y_shape = y_true . get_shape ( ) [ 1 : K . ndim ( y_true ) ] . as_list ( ) return_vars_ = np . zeros ( shape = ( len ( return_var ) ) ) for batch_num in range ( 0 , batches_per_epoch ) : feed_dict = { K . learning_phase ( ) : 1 } for input_type , input_placeholder in inputs . items ( ) : if input_type == 'Labeled' : if len ( x_labeled ) : batch_ids = np . random . choice ( len ( x_labeled ) , size = min ( batch_sizes [ input_type ] , len ( x_labeled ) ) , replace = False ) feed_dict [ input_placeholder ] = x_labeled [ batch_ids ] feed_dict [ y_true ] = y_labeled [ batch_ids ] else : feed_dict [ input_placeholder ] = x [ 0 : 0 ] feed_dict [ y_true ] = np . empty ( [ 0 ] + y_shape ) elif input_type == 'Unlabeled' : if len ( x_unlabeled ) : batch_ids = np . random . choice ( len ( x_unlabeled ) , size = batch_sizes [ input_type ] , replace = False ) feed_dict [ input_placeholder ] = x_unlabeled [ batch_ids ] else : feed_dict [ input_placeholder ] = x [ 0 : 0 ] elif input_type in [ 'Orthonorm' ] : batch_ids = np . random . choice ( len ( x ) , size = batch_sizes [ input_type ] , replace = False ) feed_dict [ input_placeholder ] = x [ batch_ids ] else : raise Exception ( "Unrecognized feed name ['{}']" . format ( input_type ) ) all_vars = return_var + updates return_vars_ += np . asarray ( K . get_session ( ) . run ( all_vars , feed_dict = feed_dict ) [ : len ( return_var ) ] ) return return_vars_
Performs one training step.
Performs one training step .
'''
    Performs one training step. Evaluates the tensors in return_var and
    updates, then returns the values of the tensors in return_var.

    return_var:         list of tensors to evaluate and return
    updates:            list of tensors to evaluate only
    x_unlabeled:        unlabeled input data
    inputs:             dictionary containing input_types and
                        input_placeholders as key, value pairs, respectively
    y_true:             true labels placeholder
    batch_sizes:        dictionary containing input_types and batch_sizes as
                        key, value pairs, respectively
    x_labeled:          labeled input data
    y_labeled:          labeled input labels
    batches_per_epoch:  parameter updates per epoch*

    returns:    the evaluated result of all tensors in return_var, summed
                across all epochs

    *note: the term epoch is used loosely here, it does not necessarily
           refer to one iteration over the entire dataset. instead, it
           is just batches_per_epoch parameter updates.
    ''' # combine data # get shape of y_true # train batches_per_epoch batches # feed corresponding input for each input_type # we have no labeled points, so feed an empty array # we have no unlabeled points, so feed an empty array
return_var
updates
x_unlabeled
inputs
y_true
batch_sizes
x_labeled
y_labeled
batches_per_epoch