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: u642k is the upper threshold of clipping
Trait Implementations§
Source§impl CustomOperationBody for Clip2K
impl CustomOperationBody for Clip2K
Source§impl<'de> Deserialize<'de> for Clip2K
impl<'de> Deserialize<'de> for Clip2K
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl Eq for Clip2K
impl StructuralPartialEq for Clip2K
Auto Trait Implementations§
impl Freeze for Clip2K
impl RefUnwindSafe for Clip2K
impl Send for Clip2K
impl Sync for Clip2K
impl Unpin for Clip2K
impl UnwindSafe for Clip2K
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.