Image for post
Image for post
Source: https://en.wikipedia.org/wiki/TensorFlow

TensorFlow 2.0 Custom Callback in Practice:An Utility for better Data Products

Callback Strategies to add incremental benefit and improve Neural Network training

Callbacks and benifits

time_period = 4000
baseline = 10
trend = trend(time,0.05)
baseline = 10
amplitude = 35
slope = 0.004
noise_level = 3
seasonality_period=400
Image for post
Image for post
Synthesized Time Series
Image for post
Image for post
moving average forecasting
Image for post
Image for post
Image for post
Image for post
ARIMA Forecasting
Image for post
Image for post
window_size = 20
batch_size = 32
shuffle_buffer_size = 1000 #To break Sequence bias
Image for post
Image for post
checkpoint_filepath = '/callback/model.h5'
model_checkpoint_callback = ModelCheckpoint(
filepath=checkpoint_filepath,
save_weights_only=True,
monitor='val_mse',
mode='min',
save_best_only=True)
Image for post
Image for post
TF2 callbacks- EarlyStop
Image for post
Image for post
Training and Validation MSE plot
Image for post
Image for post
Image for post
Image for post
Training with Custom callback subclass
lr_schedule = tf.keras.callbacks.LearningRateScheduler(
lambda epoch: 1e-8 * 10**(epoch / 20))
Image for post
Image for post
Finding optimum LR
Image for post
Image for post

Takeaways:

Sourish has 9+ years of experience in Data Science, Machine Learning,Business Analytics,Consulting across all domains, currently in Berlin with dunnhumby gmbh.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store