brainstorm/tools.py
def extract(network, iter, buffer_names):
    """Apply the network to some data and return the requested buffers.

    Batches are returned as a dictionary, with one entry for each
    requested buffer, with the data in (T, B, ...) order.

    Args:
        network (brainstorm.structure.Network):
            Network using which the features should be generated.
        iter (brainstorm.DataIterator):
            A data iterator which produces the data on which the features are
            computed.
        buffer_names (list[unicode]):
            Name of the buffer views to be saved (in dotted notation).
    Returns:
        dict[unicode, np.ndarray]
    """
    iterator = iter(handler=network.handler)
    if isinstance(buffer_names, six.string_types):
        buffer_names = [buffer_names]

    nr_examples = list(iter.data_shapes.values())[0][1]
    return_data = {}
    nr_items = 0
    for _ in run_network(network, iterator, all_inputs=False):
        network.forward_pass()
        first_pass = False if len(return_data) == len(buffer_names) else True
        for num, buffer_name in enumerate(buffer_names):
            data = network.get(buffer_name)
            if num == 0:
                nr_items += data.shape[1]
            if first_pass:
                data_shape = (data.shape[0], nr_examples) + data.shape[2:]
                return_data[buffer_name] = np.zeros(data_shape, data.dtype)
            return_data[buffer_name][:, nr_items - data.shape[1]:nr_items] = \
                data
    return return_data
Apply the network to some data and return the requested buffers.

    Batches are returned as a dictionary, with one entry for each
    requested buffer, with the data in (T, B, ...) order.

    Args:
        network (brainstorm.structure.Network):
            Network using which the features should be generated.
        iter (brainstorm.DataIterator):
            A data iterator which produces the data on which the features are
            computed.
        buffer_names (list[unicode]):
            Name of the buffer views to be saved (in dotted notation).
    Returns:
        dict[unicode, np.ndarray]
    
Apply the network to some data and return the requested buffers.
Batches are returned as a dictionary, with one entry for each
requested buffer, with the data in (T, B, ...) order.
Apply the network to some data and return the requested buffers . Batches are returned as a dictionary with one entry for each requested buffer with the data in ( T B ... ) order .
def extract(network, iter, buffer_names):
    iterator = iter(handler=network.handler)
    if isinstance(buffer_names, six.string_types):
        buffer_names = [buffer_names]
    nr_examples = list(iter.data_shapes.values())[0][1]
    return_data = {}
    nr_items = 0
    for _ in run_network(network, iterator, all_inputs=False):
        network.forward_pass()
        first_pass = False if len(return_data) == len(buffer_names) else True
        for num, buffer_name in enumerate(buffer_names):
            data = network.get(buffer_name)
            if num == 0:
                nr_items += data.shape[1]
            if first_pass:
                data_shape = (data.shape[0], nr_examples) + data.shape[2:]
                return_data[buffer_name] = np.zeros(data_shape, data.dtype)
            return_data[buffer_name][:, nr_items - data.shape[1]:nr_items] = \
                data
    return return_data
def extract ( network , iter , buffer_names ) : iterator = iter ( handler = network . handler ) if isinstance ( buffer_names , six . string_types ) : buffer_names = [ buffer_names ] nr_examples = list ( iter . data_shapes . values ( ) ) [ 0 ] [ 1 ] return_data = { } nr_items = 0 for _ in run_network ( network , iterator , all_inputs = False ) : network . forward_pass ( ) first_pass = False if len ( return_data ) == len ( buffer_names ) else True for num , buffer_name in enumerate ( buffer_names ) : data = network . get ( buffer_name ) if num == 0 : nr_items += data . shape [ 1 ] if first_pass : data_shape = ( data . shape [ 0 ] , nr_examples ) + data . shape [ 2 : ] return_data [ buffer_name ] = np . zeros ( data_shape , data . dtype ) return_data [ buffer_name ] [ : , nr_items - data . shape [ 1 ] : nr_items ] = data return return_data
Apply the network to some data and return the requested buffers.
Apply the network to some data and return the requested buffers .
"""Apply the network to some data and return the requested buffers.

    Batches are returned as a dictionary, with one entry for each
    requested buffer, with the data in (T, B, ...) order.

    Args:
        network (brainstorm.structure.Network):
            Network using which the features should be generated.
        iter (brainstorm.DataIterator):
            A data iterator which produces the data on which the features are
            computed.
        buffer_names (list[unicode]):
            Name of the buffer views to be saved (in dotted notation).
    Returns:
        dict[unicode, np.ndarray]
    """
None
network
Network using which the features should be generated.
Network using which the features should be generated .
iter
A data iterator which produces the data on which the features are
computed.
A data iterator which produces the data on which the features are computed .
buffer_names
Name of the buffer views to be saved (in dotted notation).
Name of the buffer views to be saved ( in dotted notation ) .