pub struct Clip2K {
    pub k: u64,
}
Expand description

A structure that defines the custom operation Clip2K that computes elementwise the following clipping function:

  • 0 if input <= 0,
  • input if 0 < input < 2k,
  • 2k if >= 2k.

This function is an approximation of the sigmoid function.

An array of length-n bitstrings is accepted as input. These bitstrings are interpreted as signed integers.

To use this and other custom operations in computation graphs, see Graph::custom_op.

Custom operation arguments

  • Node containing a binary array

Custom operation returns

New Clip2K node

Example

let c = create_context().unwrap();
let g = c.create_graph().unwrap();
let t = array_type(vec![2, 16], BIT);
let n1 = g.input(t.clone()).unwrap();
let n2 = g.custom_op(CustomOperation::new(Clip2K {k: 4}), vec![n1]).unwrap();

Fields

k: u64

2k is the upper threshold of clipping

Trait Implementations

Defines the logic of a custom operation. Read more

Specifies and returns the name of this custom operation. Read more

Formats the value using the given formatter. Read more

Deserialize this value from the given Serde deserializer. Read more

Feeds this value into the given Hasher. Read more

Feeds a slice of this type into the given Hasher. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Compare self to key and return true if they are equal.

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.