neon.layers.container.Multicost

class neon.layers.container.Multicost(costs, weights=None, name=None)[source]

Bases: neon.NervanaObject

Class used to compute cost from a Tree container with multiple outputs. The number of costs must match the number of outputs. Costs will be applied to the outputs in the same order that they occur in the Tree.

The targets used for the cost can either be provided from the dataset as a list or tuple, one for each cost, or, if only a single target is provided, the same target is used for all costs. This is useful for providing multiple cost branches computing the same error at different stages of the network as in GoogLeNet.

__init__(costs, weights=None, name=None)[source]

Methods

__init__(costs[, weights, name])
gen_class(pdict)
get_cost(inputs, targets) Compute the cost function over a list of inputs and targets.
get_description(**kwargs) Get layer parameters.
get_errors(inputs, targets) Get a list of errors for backpropagating to a Tree container that has multiple output nodes.
initialize(in_obj) Determine dimensions of cost and error buffers and allocate space from the input layer
recursive_gen(pdict, key) helper method to check whether the definition
be = None
classnm

Returns the class name.

cost

Get cost.

gen_class(pdict)
get_cost(inputs, targets)[source]

Compute the cost function over a list of inputs and targets.

Parameters:
  • inputs (list(Tensor)) – list of Tensors containing input values to be compared to targets
  • targets (Tensor, list(Tensor)) – either a list of Tensors containing target values, or a single target Tensor that will be mapped to each input
Returns:

Tensor containing cost

get_description(**kwargs)[source]

Get layer parameters.

Parameters:**kwargs – ignored
get_errors(inputs, targets)[source]

Get a list of errors for backpropagating to a Tree container that has multiple output nodes.

Parameters:
  • inputs (list(Tensor)) – list of Tensors containing input values to be compared to targets
  • targets (Tensor, list(Tensor)) – either a list of Tensors containing target values, or a single target Tensor that will be mapped to each input
Returns:

list of Tensors containing errors for each input

initialize(in_obj)[source]

Determine dimensions of cost and error buffers and allocate space from the input layer

Parameters:in_obj (Layer) – input layer from which to calculate costs
modulenm

Returns the full module path.

outputs

Get outputs.

recursive_gen(pdict, key)

helper method to check whether the definition dictionary is defining a NervanaObject child, if so it will instantiate that object and replace the dictionary element with an instance of that object