From a201646d77fa35dd9a5c53894d46b1d32c112805 Mon Sep 17 00:00:00 2001 From: NeTT Date: Wed, 4 Sep 2024 09:52:42 +0530 Subject: [PATCH] finalize nadam --- src/core/api/optimizer.ts | 8 ++++++++ src/core/types.ts | 1 + 2 files changed, 9 insertions(+) diff --git a/src/core/api/optimizer.ts b/src/core/api/optimizer.ts index 1b36f47..739cfc9 100644 --- a/src/core/api/optimizer.ts +++ b/src/core/api/optimizer.ts @@ -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 = { @@ -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; diff --git a/src/core/types.ts b/src/core/types.ts index df8f85a..d0ef9cb 100644 --- a/src/core/types.ts +++ b/src/core/types.ts @@ -149,6 +149,7 @@ export enum Cost { export enum OptimizerType { SGD = "sgd", Adam = "adam", + Nadam = "nadam", RMSProp = "rmsprop" }