pub struct LoopLayerParams {
pub max_loop_iterations: u64,
pub condition_var: String,
pub condition_network: Option<NeuralNetwork>,
pub body_network: Option<NeuralNetwork>,
}Expand description
Loop Layer
A layer that provides the functionality of a “for” loop or a “while” loop.
There are either no inputs or 1 input. When an input is present, it corresponds to the maximum loop count, in that case the value of the “maxLoopIterations” field is ignored. Input must be a scalar. (For description below, maxLoopIterations is assumed to be the value of the input, when its present)
No outputs are produced. Blobs produced by the condition or the body network are visible in the scope of the overall network.
“conditionNetwork” must produce a tensor with the name specified in the “conditionVar” field.
There are 3 possible cases for determining the termination condition:
Case 1:
If there is no “conditionNetwork”, in this case the layer corresponds to a pure for loop, which is run “maxLoopIterations” number of times. Equivalent pseudo-code:
for loopIterator = 0 : maxLoopIterations bodyNetwork()
Case 2:
“conditionNetwork” is present, and “maxLoopIterations” is 0 and there is no input, in this case the layer corresponds to a while loop. Equivalent pseudo-code:
conditionVar = conditionNetwork() while conditionVar: bodyNetwork() conditionVar = conditionNetwork()
Case 3:
“conditionNetwork” is provided, and “maxLoopIterations” is positive or there is an input, in this case the layer corresponds to a while loop with a joint condition. Equivalent pseudo-code:
loopIterator = 0 conditionVar = conditionNetwork() while (conditionVar and loopIterator < maxLoopIterations): bodyNetwork() loopIterator = loopIterator + 1 conditionVar = conditionNetwork()
Fields§
§max_loop_iterations: u64maximum number of iterations. Ignored if input is present.
condition_var: StringThis field provides the name of the tensor which is produced by the conditionNetwork and whose value is checked to start/continue/terminate the loop. Value close to 0.0f is treated as False. This field is optional. Must be a non empty string if and only if “conditionNetwork” is present.
condition_network: Option<NeuralNetwork>Must generate a tensor with the name provided in the “conditionVar” field. This field is optional. Must be present if and only if “conditionVar” field is a non empty string.
body_network: Option<NeuralNetwork>Body of the loop. This field must be present.
Trait Implementations§
Source§impl Clone for LoopLayerParams
impl Clone for LoopLayerParams
Source§fn clone(&self) -> LoopLayerParams
fn clone(&self) -> LoopLayerParams
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for LoopLayerParams
impl Debug for LoopLayerParams
Source§impl Default for LoopLayerParams
impl Default for LoopLayerParams
Source§impl Message for LoopLayerParams
impl Message for LoopLayerParams
Source§fn encoded_len(&self) -> usize
fn encoded_len(&self) -> usize
Source§fn encode(&self, buf: &mut impl BufMut) -> Result<(), EncodeError>where
Self: Sized,
fn encode(&self, buf: &mut impl BufMut) -> Result<(), EncodeError>where
Self: Sized,
Source§fn encode_to_vec(&self) -> Vec<u8> ⓘwhere
Self: Sized,
fn encode_to_vec(&self) -> Vec<u8> ⓘwhere
Self: Sized,
Source§fn encode_length_delimited(
&self,
buf: &mut impl BufMut,
) -> Result<(), EncodeError>where
Self: Sized,
fn encode_length_delimited(
&self,
buf: &mut impl BufMut,
) -> Result<(), EncodeError>where
Self: Sized,
Source§fn encode_length_delimited_to_vec(&self) -> Vec<u8> ⓘwhere
Self: Sized,
fn encode_length_delimited_to_vec(&self) -> Vec<u8> ⓘwhere
Self: Sized,
Source§fn decode(buf: impl Buf) -> Result<Self, DecodeError>where
Self: Default,
fn decode(buf: impl Buf) -> Result<Self, DecodeError>where
Self: Default,
Source§fn decode_length_delimited(buf: impl Buf) -> Result<Self, DecodeError>where
Self: Default,
fn decode_length_delimited(buf: impl Buf) -> Result<Self, DecodeError>where
Self: Default,
Source§fn merge(&mut self, buf: impl Buf) -> Result<(), DecodeError>where
Self: Sized,
fn merge(&mut self, buf: impl Buf) -> Result<(), DecodeError>where
Self: Sized,
self. Read moreSource§fn merge_length_delimited(&mut self, buf: impl Buf) -> Result<(), DecodeError>where
Self: Sized,
fn merge_length_delimited(&mut self, buf: impl Buf) -> Result<(), DecodeError>where
Self: Sized,
self.Source§impl PartialEq for LoopLayerParams
impl PartialEq for LoopLayerParams
Source§fn eq(&self, other: &LoopLayerParams) -> bool
fn eq(&self, other: &LoopLayerParams) -> bool
self and other values to be equal, and is used by ==.