Skip to content

Commit

Permalink
finalize nadam
Browse files Browse the repository at this point in the history
  • Loading branch information
retraigo committed Sep 4, 2024
1 parent 9f88aba commit a201646
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/core/api/optimizer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { OptimizerType } from "../types.ts";
export type Optimizer =
| { type: OptimizerType.SGD }
| { type: OptimizerType.Adam; config: AdamOptimizerConfig }
| { type: OptimizerType.Nadam; config: AdamOptimizerConfig }
| { type: OptimizerType.RMSProp; config: RMSPropOptimizerConfig };

export type AdamOptimizerConfig = {
Expand All @@ -27,6 +28,13 @@ export function AdamOptimizer(config: AdamOptimizerConfig = {}): Optimizer {
return { type: OptimizerType.Adam, config };
}

export function NadamOptimizer(config: AdamOptimizerConfig = {}): Optimizer {
config.beta1 = config.beta1 || 0.9;
config.beta2 = config.beta2 || 0.999;
config.epsilon = config.epsilon || 1e-8;
return { type: OptimizerType.Nadam, config };
}

export function RMSPropOptimizer(config: RMSPropOptimizerConfig = {}): Optimizer {
config.decayRate = config.decayRate || 0.9;
config.epsilon = config.epsilon || 1e-8;
Expand Down
1 change: 1 addition & 0 deletions src/core/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ export enum Cost {
export enum OptimizerType {
SGD = "sgd",
Adam = "adam",
Nadam = "nadam",
RMSProp = "rmsprop"
}

Expand Down

0 comments on commit a201646

Please sign in to comment.