keras-team / keras-contrib

Keras community contributions
MIT License
1.58k stars 650 forks source link

Callback for monitoring & controlling a training process using a Telegram bot #410

Open eyalzk opened 5 years ago

eyalzk commented 5 years ago

Hi! I have developed a nice feature that I use with Keras and thought it could be a useful addition to the contrib API. It allows getting automatic loss & metrics updates to the Telegram app using a dedicated callback.

Please let me know if this is a good fit for keras-contrib and I will start working on a PR

Features include:

Full details available in this repo and this post

Usage depends on the telegram-pyhton-api. However, dependencies in callbacks are not new (exist for example in RemoteMonitor callback).

Including this in Keras will require some changes to my implementation, which I will happily do, but I wanted to check if this is something that people would want before making any adjustments.

Usage: If approved, I will merge the bot class into the callback class. Then, usage will look something like this:

#  imports
from Keras_contrib.callbacks import TelegramBotCallback

telegram_token = "TOKEN"  # Replace TOKEN with your bot's token

#  User id is optional, however highly recommended as it limits the access to you alone.
telegram_user_id = None  # integer

# Create a TelegramBotCallback instance
telegram_callback = TelegramBotCallback(token=telegram_token, user_id=telegram_user_id)

# Build your model...

# Add telegram_callback to the list of callbacks passed to model.fit:
model.fit(x_train, y_train,
          batch_size=batch_size,
          epochs=epochs,
          verbose=1,
          validation_data=(x_test, y_test),
          callbacks=[telegram_callback])

And your bot will automatically start interacting with the training process. Working example and screenshots are available in the Telegrad repo.

So what do you think?

gabrieldemarmiesse commented 5 years ago

I think it's a cool tool. If you are willing to code it and maintain it, it will be merged into keras-contrib without any problem. :)

eyalzk commented 5 years ago

Thanks! I might need some advice on design choices and testing. I will submit a preliminary PR soon and I guess we'll go from there.