API Reference
tf_notify.callbacks.slack.SlackCallback
Bases: BaseNotificationCallback
A custom tf.callbacks.Callback that provides instant integration with Slack messaging app.
Attributes:
Name | Type | Description |
---|---|---|
webhook_url |
str
|
an Incoming Webhook URL for a given workspace and channel. You can generate one over at: https://my.slack.com/services/new/incoming-webhook/ |
Examples:
>>> import tensorflow as tf
>>> from tf_notify import SlackCallback
>>>
>>> model = tf.keras.Sequential(name="neural-network")
>>> model.add(tf.keras.layers.Dense(1, input_dim=784))
>>> model.compile(
>>> optimizer=tf.keras.optimizers.RMSprop(learning_rate=0.1),
>>> loss="mean_squared_error",
>>> metrics=["mean_absolute_error"],
>>> )
>>>
>>> model.fit(
>>> x_train,
>>> y_train,
>>> batch_size=128,
>>> epochs=2,
>>> verbose=0,
>>> validation_split=0.5,
>>> callbacks=[
>>> SlackCallback(webhook_url="https://url.to/webhook")
>>> ],
>>> )
Note: Any attributes or methods prefixed with _underscores are forming a so called "private" API, and is for internal use only. They may be changed or removed at anytime.
Source code in tf_notify/callbacks/slack.py
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
|
tf_notify.callbacks.telegram.TelegramCallback
Bases: BaseNotificationCallback
A custom tf.callbacks.Callback that provides instant integration with Telegram messaging app.
Attributes:
Name | Type | Description |
---|---|---|
token |
str
|
The token of the Telegram bot you would like to use. For more on Telegram bots (and how to create one yourself) see: https://core.telegram.org/bots |
chat_id |
int
|
The unique ID that corresponds to the Telegram chat you would like to send messages to. For an example on how to retrieve the |
Examples:
>>> import tensorflow as tf
>>> from tf_notify import TelegramCallback
>>>
>>> model = tf.keras.Sequential(name="neural-network")
>>> model.add(tf.keras.layers.Dense(1, input_dim=784))
>>> model.compile(
>>> optimizer=tf.keras.optimizers.RMSprop(learning_rate=0.1),
>>> loss="mean_squared_error",
>>> metrics=["mean_absolute_error"],
>>> )
>>>
>>> model.fit(
>>> x_train,
>>> y_train,
>>> batch_size=128,
>>> epochs=2,
>>> verbose=0,
>>> validation_split=0.5,
>>> callbacks=[
>>> TelegramCallback(token="XXXX:YYYY", chat_id=-1234)
>>> ],
>>> )
Note: Any attributes or methods prefixed with _underscores are forming a so called "private" API, and is for internal use only. They may be changed or removed at anytime.
Source code in tf_notify/callbacks/telegram.py
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
|
tf_notify.callbacks.email.EmailCallback
Bases: BaseNotificationCallback
A custom tf.callbacks.Callback that enables sending email messages to SMTP servers.
Keep in mind that in order to authenticate against an SMTP server (e.g. smtp.mail.yahoo.com), you will have to first generate a one-time password (or equivalent) from the respective email provider.
Attributes:
Name | Type | Description |
---|---|---|
to |
Union[str, list]
|
the email address of the recipient - can be a |
**kwargs |
Any
|
Arbitrary keyword arguments - supported keys: |
Examples:
>>> import tensorflow as tf
>>> from tf_notify import EmailCallback
>>>
>>> model = tf.keras.Sequential(name="neural-network")
>>> model.add(tf.keras.layers.Dense(1, input_dim=784))
>>> model.compile(
>>> optimizer=tf.keras.optimizers.RMSprop(learning_rate=0.1),
>>> loss="mean_squared_error",
>>> metrics=["mean_absolute_error"],
>>> )
>>>
>>> model.fit(
>>> x_train,
>>> y_train,
>>> batch_size=128,
>>> epochs=2,
>>> verbose=0,
>>> validation_split=0.5,
>>> callbacks=[
>>> EmailCallback(
>>> to="toaddress@yahoo.com",
>>> from_="fromaddress@yahoo.com",
>>> host="smtp.mail.yahoo.com",
>>> port=465,
>>> username="my-cool-username",
>>> password="my-cool-password", # one-time app password
>>> ssl=True,
>>> )
>>> ],
>>> )
Note: Any attributes or methods prefixed with _underscores are forming a so called "private" API, and is for internal use only. They may be changed or removed at anytime.
Source code in tf_notify/callbacks/email.py
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
|