Skip to content

Commit 7a8317c

Browse files
feat: Provide RNN a means of formatting
For use with https://github.com/BrainJS/train-stream/
1 parent 2ef25fd commit 7a8317c

File tree

3 files changed

+11
-3
lines changed

3 files changed

+11
-3
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,5 +113,5 @@
113113
},
114114
"types": "dist/src",
115115
"unpkg": "dist/browser.js",
116-
"version": "2.0.0-beta.17"
116+
"version": "2.0.0-beta.18"
117117
}

src/recurrent/rnn-time-step.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -809,6 +809,8 @@ export class RNNTimeStep extends RNN {
809809
return result;
810810
}
811811

812+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
813+
// @ts-expect-error
812814
formatData(data: FormattableData[]): Float32Array[][] {
813815
const dataShape = lookup.dataShape(data).join(',');
814816
switch (dataShape) {

src/recurrent/rnn.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -645,8 +645,14 @@ export class RNN {
645645
};
646646
}
647647

648-
addFormat(): void {
649-
throw new Error('not yet implemented');
648+
addFormat(data: Value): void {}
649+
650+
formatData(data: Value[]): number[][] {
651+
const result = [];
652+
for (let i = 0; i < data.length; i++) {
653+
result.push(this.options.dataFormatter.formatDataIn(data[i]));
654+
}
655+
return result;
650656
}
651657

652658
toJSON(): IRNNJSON {

0 commit comments

Comments
 (0)