pub struct JvpCreateGraphResult<'g> { /* private fields */ }Expand description
jvp_create_graph の結果(イシュー #3067・設計記録 §31.1)。孫テープ上の追跡された J·v と、
元テープの Var から孫テープ上の写し(親→子→孫の 2 段合成)を引く対応表を持つ。
公開型に出るライフタイムは孫テープの 'g だけ(1 段目の子テープは関数内に閉じる)。
Implementations§
Source§impl<'g> JvpCreateGraphResult<'g>
impl<'g> JvpCreateGraphResult<'g>
Sourcepub fn output(&self) -> Var<'g>
pub fn output(&self) -> Var<'g>
J·v(shape は元の output と同じ)を孫テープ上の Var として返す。
写しの入力へ grandchild.backward で微分できる。出力が入力に依存しない場合
(線形・var_no_grad の係数のみ等)は追跡なし(requires_grad() == false)になりうる。
Sourcepub fn child_var(
&self,
parent_var: &Var<'_>,
) -> Result<Option<Var<'g>>, AutodiffError>
pub fn child_var( &self, parent_var: &Var<'_>, ) -> Result<Option<Var<'g>>, AutodiffError>
元テープ上の parent_var の孫テープ上の写しを返す。output() を grandchild.backward で
微分した勾配はこの写しをキーに読む(元の x とは直接つながらない。§31.2)。
- テープ・世代の不一致 →
Err(TapeMismatch)、追跡なし →Err(GradientTrackingDisabled)(CreateGraphResult::child_varと同じ検査順)。 Ok(None)はJ·vがその入力に恒等的に依存しない(勾配ゼロ)ことを意味する。
Trait Implementations§
Auto Trait Implementations§
impl<'g> !RefUnwindSafe for JvpCreateGraphResult<'g>
impl<'g> !Send for JvpCreateGraphResult<'g>
impl<'g> !Sync for JvpCreateGraphResult<'g>
impl<'g> !UnwindSafe for JvpCreateGraphResult<'g>
impl<'g> Freeze for JvpCreateGraphResult<'g>
impl<'g> Unpin for JvpCreateGraphResult<'g>
impl<'g> UnsafeUnpin for JvpCreateGraphResult<'g>
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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