Provides @Symbolic annotation to create symbolic methods, in which you can create Layers from mathematical formulas.
Symbolic is a dependenttype class that calculates a specific Layer type according to NativeOutput.
Combining with implicit-dependent-type compiler plugin,
it can be treated as a type annotation in the form of NativeOutput @Symbolic, converting NativeOutput to a specific Layer type.
This member is added by an implicit conversion from Symbolic[NativeOutput] to
any2stringadd[Symbolic[NativeOutput]] performed by method any2stringadd in scala.Predef.
This member is added by an implicit conversion from Symbolic[NativeOutput] to
ArrowAssoc[Symbolic[NativeOutput]] performed by method ArrowAssoc in scala.Predef.
This member is added by an implicit conversion from Symbolic[NativeOutput] to
Ensuring[Symbolic[NativeOutput]] performed by method Ensuring in scala.Predef.
This member is added by an implicit conversion from Symbolic[NativeOutput] to
Ensuring[Symbolic[NativeOutput]] performed by method Ensuring in scala.Predef.
This member is added by an implicit conversion from Symbolic[NativeOutput] to
Ensuring[Symbolic[NativeOutput]] performed by method Ensuring in scala.Predef.
This member is added by an implicit conversion from Symbolic[NativeOutput] to
Ensuring[Symbolic[NativeOutput]] performed by method Ensuring in scala.Predef.
This member is added by an implicit conversion from Symbolic[NativeOutput] to
StringFormat[Symbolic[NativeOutput]] performed by method StringFormat in scala.Predef.
Definition Classes
StringFormat
Annotations
@inline()
defforward: ((input: _62.Input)_62.Output) forSome {val _62: Layer { ... /* 2 definitions in type refinement */ }}
Implicit information
This member is added by an implicit conversion from Symbolic[NativeOutput] to
Aux[Input, Aux[OutputData, OutputDelta]] performed by method autoToLayer in com.thoughtworks.deeplearning.Symbolic.
This conversion will take place only if an implicit value of type Aux[Symbolic[NativeOutput], Input, OutputData, OutputDelta] is in scope.
This member is added by an implicit conversion from Symbolic[NativeOutput] to
ToLayerOps[Symbolic[NativeOutput], Input, OutputData, OutputDelta] performed by method ToLayerOps in com.thoughtworks.deeplearning.Symbolic.
This conversion will take place only if an implicit value of type Aux[Symbolic[NativeOutput], Input, OutputData, OutputDelta] is in scope.
This member is added by an implicit conversion from Symbolic[NativeOutput] to
ToTapeOps[Symbolic[NativeOutput], Data, Delta] performed by method ToTapeOps in com.thoughtworks.deeplearning.Symbolic.
This conversion will take place only if an implicit value of type Aux[Symbolic[NativeOutput], Data, Delta] is in scope.
This member is added by an implicit conversion from Symbolic[NativeOutput] to
ArrowAssoc[Symbolic[NativeOutput]] performed by method ArrowAssoc in scala.Predef.
Definition Classes
ArrowAssoc
Inherited from AnyRef
Inherited from Any
Inherited by implicit conversion autoToLayer from
Symbolic[NativeOutput] to Aux[Input, Aux[OutputData, OutputDelta]]
Inherited by implicit conversion ToTapeOps from
Symbolic[NativeOutput] to ToTapeOps[Symbolic[NativeOutput], Data, Delta]
Inherited by implicit conversion ToLayerOps from
Symbolic[NativeOutput] to ToLayerOps[Symbolic[NativeOutput], Input, OutputData, OutputDelta]
Inherited by implicit conversion any2stringadd from
Symbolic[NativeOutput] to any2stringadd[Symbolic[NativeOutput]]
Inherited by implicit conversion StringFormat from
Symbolic[NativeOutput] to StringFormat[Symbolic[NativeOutput]]
Inherited by implicit conversion Ensuring from
Symbolic[NativeOutput] to Ensuring[Symbolic[NativeOutput]]
Inherited by implicit conversion ArrowAssoc from
Symbolic[NativeOutput] to ArrowAssoc[Symbolic[NativeOutput]]
Provides
@Symbolic
annotation to create symbolic methods, in which you can create Layers from mathematical formulas.Symbolic
is a dependent type class that calculates a specific Layer type according toNativeOutput
. Combining with implicit-dependent-type compiler plugin, it can be treated as a type annotation in the form ofNativeOutput @Symbolic
, convertingNativeOutput
to a specific Layer type.@Symbolic
的三种用法用于符号方法的隐式参数类型
如果某个方法的隐式类型参数标注了
@Symbolic
,那么这个方法就是符号方法,@Symbolic
所标注的隐式参数类型是这个符号方法的输入类型。 这种情况下,NativeOutput @Symbolic
会被展开为:例如:
上述代码中,由于
INDArray
的导数类型也是INDArray
,所以sumNetwork
的输入类型INDArray @Symbolic
展开后是Identity[INDArray, INDArray]
。用于符号方法内部变量和返回值
在符号方法内部和返回值处,
NativeOutput @Symbolic
会被展开为:例如:
上述代码中,
expScores
的类型INDArray @Symbolic
展开后是:而
result
的类型Double @Symbolic
展开后是:用于符号方法之外
在符号方法之外,
(NativeInput => NativeOutput) @Symbolic
会被展开为:例如:
上述代码中,
predictor
的类型(INDArray => Double) @Symbolic
展开后是:定制符号类型
@Symbolic
通过检查Symbolic.ToLiteral隐式值来确定原生类型和导数之间的映射关系。 因此,只要定义Symbolic.ToLiteral类型的隐式值,@Symbolic
就可以支持定制符号类型。比如,假如你希望支持
Short @Symbolic
,其中使用Float作为Short的导数类型,那么可以这样做:这样一来
shortNetwork
的类型就会展开为:Layer.Tape#Delta
Symbolic.ToLiteral
Symbolic.Layers.Identity