Skip to content

Commit

Permalink
Update some files
Browse files Browse the repository at this point in the history
  • Loading branch information
itsubaki committed Oct 22, 2023
1 parent b39bb1a commit 43e466a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 12 deletions.
10 changes: 3 additions & 7 deletions cmd/lstm/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,15 @@ type SinCurve struct {
func NewSinCurve() *SinCurve {
N, noise := 1000, 0.05

x := make([]float64, N)
for i := 0; i < N; i++ {
x[i] = 2 * math.Pi * float64(i) / float64(N-1)
}

y := make([]float64, N)
for i := 0; i < N; i++ {
y[i] = math.Sin(x[i]) + rand.Float64()*(2*noise) - noise
x := 2 * math.Pi * float64(i) / float64(N-1)
y[i] = math.Sin(x) + rand.Float64()*(2*noise) - noise
}

return &SinCurve{
N: N,
Data: y[:len(x)-1],
Data: y[:len(y)-1],
Label: y[1:],
}
}
Expand Down
10 changes: 5 additions & 5 deletions optimizer/adam.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,17 @@ func (o *Adam) LearningRate() float64 {
}

func (o *Adam) Update(model Model) {
params := Params(model)
for _, h := range o.Hooks {
h(params)
}

o.iter++
if len(o.ms) == 0 {
o.ms = make(map[string]matrix.Matrix)
o.vs = make(map[string]matrix.Matrix)
}

params := Params(model)
for _, h := range o.Hooks {
h(params)
}

for _, p := range params {
if _, ok := o.ms[id(p)]; !ok {
o.ms[id(p)] = matrix.ZeroLike(p.Data)
Expand Down

0 comments on commit 43e466a

Please sign in to comment.