Auxiliar Layers

Constant Of Tensor

layer eddl::ConstOfTensor(Tensor *t, string name = "")

Given a tensor (constant), this layer outputs the same tensor but repeat across the batch.

Parameters
  • Tensor – Raw tensor

  • name – A name for the operation

Returns

Raw repeated for each batch

Example:

// Example #1:
Tensor *t = Tensor::ones({16, 16, 16}};
Layer *l = ConstOfTensor(t);

// Example #2:
layer mean = ConstOfTensor(new Tensor( {0.485, 0.456, 0.406}, {3}, DEV_CPU));
layer std = ConstOfTensor(new Tensor( {0.229, 0.224, 0.225}, {3}, DEV_CPU));

Where

layer eddl::Where(layer parent1, layer parent2, layer condition, string name = "")

Return elements chosen from x or y depending on condition.

Parameters
  • parent1 – Parent layer

  • parent2 – Parent layer

  • condition – Condition layer. Where True, selects parent1; where False, selects parent2. (Bool => Float of 0.0s and 1.0s)

  • name – A name for the operation

Returns

Raw repeated for each batch

Example:

l = Where(parent1, parent2, condition);

Bypass

layer eddl::Bypass(layer parent, string bypass_name = "", string name = "")

Virtual layer. Propagates the output of the parent as their own. Used internally for ONNX.

Parameters
  • parent – Parent layer

  • bypass_name – Name of the layer being bypassed (e.g.: “bypass_unknown_layer)

Returns

Output of repeat operation

Example:

// Example #1:
Layer *l = Bypass(l, "fake_layer");

Shape

layer eddl::Shape(layer parent, bool include_batch = true, string name = "")

This layer returns the shape of its parent as his output.

Parameters
  • parent – Parent layer

  • include_batch – If True, the batch dimension is included in the output

Returns

Output of repeat operation

Example:

// Example #1:
Layer *l = Shape(l, true);