public struct Context
A context that stores thread-local contextual information used by deep learning APIs such as layers.
Use Context.local
to retrieve the current thread-local context.
Examples:
- Set the current learning phase to training so that layers like
BatchNorm
will compute mean and variance when applied to inputs.
Context.local.learningPhase = .training
- Set the current learning phase to inference so that layers like
Dropout
will not drop out units when applied to inputs.
Context.local.learningPhase = .inference
-
The learning phase.
Declaration
public var learningPhase: LearningPhase
-
The random seed.
Note
Whenever obtained, the random seed is also updated so that future stateless random TensorFlow op executions will result in non-deterministic results.Declaration
public var randomSeed: TensorFlowSeed { mutating get set }
-
Creates a context with default properties.
Declaration
public init()
-
The current thread-local context.
Note
Accessing this property is thread-safe.Declaration
public static var local: Context { get set }