Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Magic Function TensorBoard #611

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
feat: update file helper_functions
sc0v0ne committed Jan 14, 2024
commit 840271826d1e8d569235b791c2b2338a053ecd63
27 changes: 15 additions & 12 deletions extras/helper_functions.py
Original file line number Diff line number Diff line change
@@ -2,6 +2,8 @@
### Storing them here so they're easily accessible.

import tensorflow as tf
import datetime
import os

# Create a function to import an image and resize it to be able to be used with our model
def load_and_prep_image(filename, img_shape=224, scale=True):
@@ -131,27 +133,28 @@ def pred_and_plot(model, filename, class_names):
plt.imshow(img)
plt.title(f"Prediction: {pred_class}")
plt.axis(False);

import datetime

def create_tensorboard_callback(dir_name, experiment_name):

def create_tensorboard_callback(experiment_name):
"""
Creates a TensorBoard callback instand to store log files.
Creates a TensorBoard callback instand to store log files.

Stores log files with the filepath:
"dir_name/experiment_name/current_datetime/"
Stores log files with the filepath:
"dir_name/experiment_name/current_datetime/"

Args:
dir_name: target directory to store TensorBoard log files
experiment_name: name of experiment directory (e.g. efficientnet_model_1)
Args:
dir_name: target directory to store TensorBoard log files
experiment_name: name of experiment directory (e.g. efficientnet_model_1)
"""
log_dir = dir_name + "/" + experiment_name + "/" + datetime.datetime.now().strftime("%Y%m%d-%H%M%S")
logfit_dir = "logs/fit/"
path_experiment = (os.path.join(logfit_dir, experiment_name, datetime.datetime.now().strftime("%Y%m%d-%H%M%S")))
tensorboard_callback = tf.keras.callbacks.TensorBoard(
log_dir=log_dir
log_dir=path_experiment
)
print(f"Saving TensorBoard log files to: {log_dir}")
print(f"Saving TensorBoard log files to: {logfit_dir}")
return tensorboard_callback


# Plot the validation and training data separately
import matplotlib.pyplot as plt