Skip to content

Commit 23056e6

Browse files
committed
fixed CharRNN training code to match C# ranges semantics
1 parent 3b68070 commit 23056e6

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

CharRNN/CharRNNUtils.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,12 +67,11 @@ void CreateBatches() {
6767
if (this.batchCount == 0)
6868
throw new ArgumentException();
6969

70-
// TODO implement and use C# 8 indexing here
71-
this.tensor = this.tensor[..this.batchCount * this.batchSize * this.seqLength];
70+
this.tensor = this.tensor[..this.batchCount * this.batchSize * this.seqLength-1];
7271
_ArrayLike xdata = this.tensor;
7372
_ArrayLike ydata = np.copy(this.tensor);
7473
ydata[..^1] = xdata[1..];
75-
ydata[^1] = xdata[0];
74+
ydata[^0] = xdata[0];
7675
this.x_batches = np.split((ndarray)xdata.reshape((this.batchSize, -1)), this.batchCount, 1);
7776
this.y_batches = np.split((ndarray)ydata.reshape((this.batchSize, -1)), this.batchCount, 1);
7877
}

0 commit comments

Comments
 (0)