Spaces:
Runtime error
Runtime error
Download custom_callbacks.py from RealTimeLiveAIForHealth/WebcamObjectRecognition: direct link, hf CLI and curl.
- Browser
- Download file 585 Bytes
-
https://huggingface.co/spaces/RealTimeLiveAIForHealth/WebcamObjectRecognition/resolve/main/custom_callbacks.py
- Command line
-
hf download hf://spaces/RealTimeLiveAIForHealth/WebcamObjectRecognition/custom_callbacks.py
-
curl -L -o custom_callbacks.py https://huggingface.co/spaces/RealTimeLiveAIForHealth/WebcamObjectRecognition/resolve/main/custom_callbacks.py
585 Bytes
| from tensorflow.keras import callbacks | |
| import math | |
| class CosineAnnealingScheduler(callbacks.LearningRateScheduler): | |
| def __init__(self, epochs_per_cycle, lr_min, lr_max, verbose=0): | |
| super(callbacks.LearningRateScheduler, self).__init__() | |
| self.verbose = verbose | |
| self.lr_min = lr_min | |
| self.lr_max = lr_max | |
| self.epochs_per_cycle = epochs_per_cycle | |
| def schedule(self, epoch, lr): | |
| return self.lr_min + (self.lr_max - self.lr_min) *\ | |
| (1 + math.cos(math.pi * (epoch % self.epochs_per_cycle) / self.epochs_per_cycle)) / 2 |