trait
Symbolic[NativeOutput] extends AnyRef
Type Members
-
abstract
type
@ <: Layer
Value Members
-
final
def
!=(arg0: AnyRef): Boolean
-
final
def
!=(arg0: Any): Boolean
-
final
def
##(): Int
-
def
+(other: String): String
-
def
->[B](y: B): (Symbolic[NativeOutput], B)
-
final
def
==(arg0: AnyRef): Boolean
-
final
def
==(arg0: Any): Boolean
-
final
def
asInstanceOf[T0]: T0
-
def
clone(): AnyRef
-
def
ensuring(cond: (Symbolic[NativeOutput]) ⇒ Boolean, msg: ⇒ Any): Symbolic[NativeOutput]
-
def
ensuring(cond: (Symbolic[NativeOutput]) ⇒ Boolean): Symbolic[NativeOutput]
-
def
ensuring(cond: Boolean, msg: ⇒ Any): Symbolic[NativeOutput]
-
def
ensuring(cond: Boolean): Symbolic[NativeOutput]
-
final
def
eq(arg0: AnyRef): Boolean
-
def
equals(arg0: Any): Boolean
-
def
finalize(): Unit
-
def
formatted(fmtstr: String): String
-
def
forward: ((input: _63.Input)_63.Output) forSome {val _63: Layer { ... /* 2 definitions in type refinement */ }}
-
final
def
getClass(): Class[_]
-
def
hashCode(): Int
-
final
def
isInstanceOf[T0]: Boolean
-
final
def
ne(arg0: AnyRef): Boolean
-
final
def
notify(): Unit
-
final
def
notifyAll(): Unit
-
final
def
synchronized[T0](arg0: ⇒ T0): T0
-
def
toLayer: Aux[Input, Aux[OutputData, OutputDelta]]
-
def
toString(): String
-
def
toTape: Aux[Data, Delta]
-
final
def
wait(): Unit
-
final
def
wait(arg0: Long, arg1: Int): Unit
-
final
def
wait(arg0: Long): Unit
-
def
→[B](y: B): (Symbolic[NativeOutput], B)
Shadowed Implicit Value Members
-
val
self: Any
-
val
self: Any
Deprecated Value Members
-
def
x: Symbolic[NativeOutput]
-
def
x: Symbolic[NativeOutput]
Inherited from AnyRef
Inherited from Any
Inherited by implicit conversion autoToLayer from
Symbolic[NativeOutput] to Aux[Input, Aux[OutputData, OutputDelta]]
Inherited by implicit conversion ToLayerOps from
Symbolic[NativeOutput] to ToLayerOps[Symbolic[NativeOutput], Input, OutputData, OutputDelta]
Inherited by implicit conversion any2stringadd from
Symbolic[NativeOutput] to StringAdd
Inherited by implicit conversion any2ArrowAssoc from
Symbolic[NativeOutput] to ArrowAssoc[Symbolic[NativeOutput]]
Inherited by implicit conversion any2Ensuring from
Symbolic[NativeOutput] to Ensuring[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