A small notification package providing keras events on Telegram or Slack
Project description
Keras Notify Callback
A Tensorflow/Keras callback which sends information about your model training, on various messaging platforms.
Installation
Using pip
:
pip install keras-notify
Usage
Import the required module and add it to the list callbacks while training your model.
Example:
>>> from keras-notify import TelegramCallback
>>> telegram_callback = TelegramCallback('<BotToken>',
'<ChatID>',
'CNN Model',
['loss', 'val_loss'],
['accuracy', 'val_accuracy'],
True)
>>> model.fit(x_train, y_train,
batch_size=32,
epochs=10,
validation_data=(x_test, y_test),
callbacks=[telegram_callback])
Telegram
- Create a telegram bot using BotFather
- Search for @BotFather on telegram.
- Send
/help
to get list of all commands. - Send
/newbot
to create a new bot and complete the setup. - Copy the bot token after creating the bot.
- Get the chat ID
- Search for the bot you created and send it any random message.
- Go to this URL
https://api.telegram.org/bot<BOT_TOKEN>/getUpdates
(replace <BOT_TOKEN> with your bot token) - Copy the
chat id
of the user you want to send messages to. - You receive the
chat id
only if you send the message first and then go to the above url.
- Use the
TelegramCallback()
class.
TelegramCallback(bot_token=None, chat_id=None, modelName='model', loss_metrics=['loss'], acc_metrics=[], getSummary=False):
Arguments:
bot_token
: unique token of Telegram bot{str}
chat_id
: Telegram chat id you want to send message to{str}
modelName
: name of your model{str}
loss_metrics
: loss metrics you want in the loss graph{list of strings}
acc_metrics
: accuracy metrics you want in the accuracy graphs{list of strings}
getSummary
: Do you want message for each epoch (False) or a single message containing information about all epochs (True).{bool}
Slack
- Create a Slack workspace
- Create a new channel
- Search for the Incoming Webhooks in the Apps and install it.
- Copy the Webhook URL
- Use the
SlackCallback()
class.
SlackCallback(bot_token=None, chat_id=None, modelName='model', loss_metrics=['loss'], acc_metrics=[], getSummary=False):
Arguments:
webhookURL
: unique webhook URL of the app{str}
channel
: channel name or username you want to send message to{str}
modelName
: name of your model{str}
loss_metrics
: loss metrics you want in the loss graph{list of strings}
acc_metrics
: accuracy metrics you want in the accuracy graph{list of strings}
getSummary
: Do you want message for each epoch (False) or a single message containing information about all epochs (True).{bool}
Sending images in Slack is not supported currently.
ToDo
- Zulip
- Messages
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
keras-notify-0.0.1.tar.gz
(5.2 kB
view hashes)
Built Distribution
Close
Hashes for keras_notify-0.0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 88c79a8fd4cf5be95424d6deac4117377f9edef74fb3047fc31527c8b783f618 |
|
MD5 | e6e71b45cef10d5e44fafb4db08f4fd6 |
|
BLAKE2b-256 | a28c5d935b2fdb58f3d44c050b4a12b3ced4f6d2ff51fae249954601d3ae4d65 |