A TenosorFlow callback that texts you back (to let you know how training is going).
Project description
Text Me Keras
A TensorFlow callback that texts back... to let you know how training is going.
Have you ever found yourself at a party, all your friends are getting hundreds of texts... but not you? Well, now you can be popular. Just add this callback when training your models and it will send you a summary of your training procedure! Say goodbye to those lonely, message-free lock screens with the TextMeKeras callbacks!
Usage.
Clone and Install.
git clone https://github.com/djvaroli/text_me_keras.git && cd text_me_keras/ && pip install -e .
Or
pip install git+https://github.com/djvaroli/text_me_keras.git
Export Twilio Credentials
Note: If you don't have Twilio credentials, you can create a free account at https://www.twilio.com/. Then create a new project and get a free phone number as well as the necessary credentials.
Python
import os
os.environ["TWILIO_ACCOUNT_SID"] = <your_account_sid>
os.environ["TWILIO_AUTH_TOKEN"] = <your_auth_token>
Shell
export TWILIO_ACCOUNT_SID=<your_account_sid>
export TWILIO_AUTH_TOKEN=<your_auth_token>
Try it Out
import os
import numpy as np
from tensorflow.keras.layers import Input, Dense, Conv2D, Flatten, LeakyReLU
from tensorflow.keras.models import Model
from tensorflow.keras.datasets import mnist
from tensorflow.keras.losses import SparseCategoricalCrossentropy
from tensorflow.keras.metrics import SparseCategoricalAccuracy
from text_me_keras.callbacks import TextMeCallback
# if you haven't set the credentials before hand you'll get a warning
# set the credentials
os.environ["TWILIO_ACCOUNT_SID"] = <your_account_sid>
os.environ["TWILIO_AUTH_TOKEN"] = <your_auth_token>
# download MNIST dataset
(trainX, trainy), (testX, testy) = mnist.load_data()
print(trainX.shape, trainy.shape) # (60000, 28, 28) (60000,)
# reshape to have channel dimensions
trainX = np.expand_dims(trainX, axis=-1)
testX = np.expand_dims(testX, axis=-1)
print(trainX.shape, testX.shape) # (60000, 28, 28, 1) (60000, 28, 28, 1)
# build a model for MNIST
i = Input((28, 28, 1))
x = Conv2D(32, (5, 5), 2, padding="same", use_bias=False)(i)
x = LeakyReLU()(x)
x = Conv2D(64, (5, 5), 2, padding="same", use_bias=False)(x)
x = LeakyReLU()(x)
x = Flatten()(x)
x = Dense(10)(x)
model = Model(i, x)
# model.summary() # print the summary if you'd like to see it
# set upt the loss, metrics and compile
loss = SparseCategoricalCrossentropy(from_logits=True)
metrics = [SparseCategoricalAccuracy()]
model.compile("adam", loss, metrics=metrics)
# set up the callback
to = <number to send updates to>
from_ = <number associated with your Twilio account>
# if you haven't set the creds by this point, an exception will be raised
cbck = TextMeCallback(
send_to=to,
send_from=from_, # must be a number attached to your Twilio account
frequency=1, # num epochs between texts
run_id="Test Run"
)
model.fit(trainX, trainy, epochs=2, validation_data=[testX, testy], batch_size=256, callbacks=callbacks)
# trained with a Colab GPU
Epoch 1/2
235/235 [==============================] - 2s 7ms/step - loss: 0.6579 - sparse_categorical_accuracy: 0.9049 - val_loss: 0.1528 - val_sparse_categorical_accuracy: 0.9538
Epoch 2/2
235/235 [==============================] - 2s 6ms/step - loss: 0.1318 - sparse_categorical_accuracy: 0.9639 - val_loss: 0.1321 - val_sparse_categorical_accuracy: 0.9625
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file text_me_keras-0.1.1.tar.gz.
File metadata
- Download URL: text_me_keras-0.1.1.tar.gz
- Upload date:
- Size: 4.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.2.0 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.7.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a3362ea798130752a25d0c02c05680fb87d51a8e0ab78232a030b70310df55f1
|
|
| MD5 |
7c8b28b421c598dad5172fd5acfbb2c9
|
|
| BLAKE2b-256 |
4f22378b05e7a3fea7cae1e35ca3640fdaebb6a4127d3a8909d829a3d6e2aaf6
|
File details
Details for the file text_me_keras-0.1.1-py3-none-any.whl.
File metadata
- Download URL: text_me_keras-0.1.1-py3-none-any.whl
- Upload date:
- Size: 5.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.2.0 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.7.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f96ba03f70d5d35eca6fb753fda177309f6812a90fb1facecc480e840cdf5ab1
|
|
| MD5 |
28fc160f937790758e7a5862c7ed6f10
|
|
| BLAKE2b-256 |
cfc6fd45e883f5b7bf14bea7f9920ac91c0e82e4facec1a912cb9f9eac629d4f
|