pub struct PositionalEncoding {
pub n_freqs: usize,
pub include_input: bool,
}Expand description
Fourier positional encoding used by NeRF.
For a scalar x and n_freqs frequencies the encoding is:
[sin(2^0 x), cos(2^0 x), sin(2^1 x), cos(2^1 x), …, sin(2^{L-1} x), cos(2^{L-1} x)]
giving a vector of length 2 * n_freqs.
Fields§
§n_freqs: usizeNumber of frequency bands L.
include_input: boolWhether to include the raw input (identity) in the encoding.
Implementations§
Source§impl PositionalEncoding
impl PositionalEncoding
Sourcepub fn with_identity(n_freqs: usize) -> Self
pub fn with_identity(n_freqs: usize) -> Self
Create a new encoding including the raw input.
Sourcepub fn encode_scalar(&self, x: f64) -> Vec<f64>
pub fn encode_scalar(&self, x: f64) -> Vec<f64>
Encode a scalar x. Returns a vector of length 2 * n_freqs (or
2 * n_freqs + 1 when include_input is true).
Sourcepub fn encode(&self, x: &[f64]) -> Vec<f64>
pub fn encode(&self, x: &[f64]) -> Vec<f64>
Encode an arbitrary-length input vector by encoding each element independently and concatenating the results.
Sourcepub fn output_dim_scalar(&self) -> usize
pub fn output_dim_scalar(&self) -> usize
Output dimension for a single scalar input.
Sourcepub fn output_dim(&self, input_len: usize) -> usize
pub fn output_dim(&self, input_len: usize) -> usize
Output dimension for an input of length input_len.
Trait Implementations§
Source§impl Clone for PositionalEncoding
impl Clone for PositionalEncoding
Source§fn clone(&self) -> PositionalEncoding
fn clone(&self) -> PositionalEncoding
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for PositionalEncoding
impl RefUnwindSafe for PositionalEncoding
impl Send for PositionalEncoding
impl Sync for PositionalEncoding
impl Unpin for PositionalEncoding
impl UnsafeUnpin for PositionalEncoding
impl UnwindSafe for PositionalEncoding
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<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more