-
-
Notifications
You must be signed in to change notification settings - Fork 86
/
param.go
33 lines (29 loc) · 1.06 KB
/
param.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
// Copyright 2019 spaGO Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package nn
import (
"github.com/nlpodyssey/spago/ag"
"github.com/nlpodyssey/spago/mat"
)
// Param is the interface for a Model parameter.
type Param interface {
ag.Node
// Name returns the name of the parameter (can be empty string).
Name() string
// Type returns the type of the parameter (weights, biases, undefined).
Type() ParamsType
// SetRequiresGrad set whether the param requires gradient, or not.
SetRequiresGrad(value bool)
// ReplaceValue replaces the value of the parameter and clears the support structure.
ReplaceValue(value mat.Matrix)
// ApplyDelta updates the value applying the delta.
ApplyDelta(delta mat.Matrix)
// Payload returns the optimizer support structure (can be nil).
Payload() *Payload
// SetPayload is a thread safe operation to set the given Payload on the
// receiver Param.
SetPayload(payload *Payload)
// ClearPayload clears the support structure.
ClearPayload()
}