Skip to content
This repository was archived by the owner on Jul 1, 2023. It is now read-only.

Fix RNN gradient accumulation. #519

Merged
merged 1 commit into from
Nov 14, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Sources/TensorFlow/Layers/Recurrent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ extension RNNCellOutput: EuclideanDifferentiable

/// A recurrent neural network cell.
public protocol RNNCell: Layer
where Input == RNNCellInput<TimeStepInput, State>,
where Input == RNNCellInput<TimeStepInput, State>,
Output == RNNCellOutput<TimeStepOutput, State> {
/// The input at a time step.
associatedtype TimeStepInput: Differentiable
Expand Down Expand Up @@ -320,7 +320,7 @@ public struct RNN<Cell: RNNCell>: Layer {
reversed𝛁inputs.reserveCapacity(timeStepCount)
for (𝛁output, backpropagator) in zip(𝛁outputs.base, backpropagators).reversed() {
let (new𝛁cell, 𝛁input) = backpropagator(.init(output: 𝛁output, state: 𝛁state))
𝛁cell = new𝛁cell
𝛁cell += new𝛁cell
𝛁state = 𝛁input.state
reversed𝛁inputs.append(𝛁input.input)
}
Expand Down