catniff 0.8.16 → 0.8.17

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -30,8 +30,20 @@ export declare class CosineAnnealingLR {
30
30
  constructor(optimizer: OptimizerWithLR, TMax: number, etaMin?: number, lastEpoch?: number);
31
31
  step(): void;
32
32
  }
33
+ export interface Scheduler {
34
+ step: Function;
35
+ }
36
+ export declare class SequentialLR {
37
+ optimizer: OptimizerWithLR;
38
+ schedulers: Scheduler[];
39
+ milestones: number[];
40
+ lastEpoch: number;
41
+ constructor(optimizer: OptimizerWithLR, schedulers: Scheduler[], milestones: number[], lastEpoch?: number);
42
+ step(): void;
43
+ }
33
44
  export declare const LRScheduler: {
34
45
  StepLR: typeof StepLR;
35
46
  LinearLR: typeof LinearLR;
36
47
  CosineAnnealingLR: typeof CosineAnnealingLR;
48
+ SequentialLR: typeof SequentialLR;
37
49
  };
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.LRScheduler = exports.CosineAnnealingLR = exports.LinearLR = exports.StepLR = void 0;
3
+ exports.LRScheduler = exports.SequentialLR = exports.CosineAnnealingLR = exports.LinearLR = exports.StepLR = void 0;
4
4
  class StepLR {
5
5
  optimizer;
6
6
  stepSize;
@@ -84,8 +84,33 @@ class CosineAnnealingLR {
84
84
  }
85
85
  }
86
86
  exports.CosineAnnealingLR = CosineAnnealingLR;
87
+ class SequentialLR {
88
+ optimizer;
89
+ schedulers;
90
+ milestones;
91
+ lastEpoch;
92
+ constructor(optimizer, schedulers, milestones, lastEpoch = -1) {
93
+ this.optimizer = optimizer;
94
+ this.schedulers = schedulers;
95
+ this.milestones = milestones;
96
+ this.lastEpoch = lastEpoch;
97
+ }
98
+ step() {
99
+ this.lastEpoch++;
100
+ let schedulerIndex = this.schedulers.length - 1; // default to last
101
+ for (let index = 0; index < this.milestones.length; index++) {
102
+ if (this.lastEpoch < this.milestones[index]) {
103
+ schedulerIndex = index;
104
+ break;
105
+ }
106
+ }
107
+ this.schedulers[schedulerIndex].step();
108
+ }
109
+ }
110
+ exports.SequentialLR = SequentialLR;
87
111
  exports.LRScheduler = {
88
112
  StepLR,
89
113
  LinearLR,
90
- CosineAnnealingLR
114
+ CosineAnnealingLR,
115
+ SequentialLR
91
116
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "catniff",
3
- "version": "0.8.16",
3
+ "version": "0.8.17",
4
4
  "description": "Torch-like deep learning framework for Javascript",
5
5
  "main": "./dist/index.js",
6
6
  "scripts": {