Tensorflow is out with the new Tensorflow2.0.0-alpha and it also brings some new features. And We will talk about what’s new in
You can look at some new features in new and updated tensorboard:
Let’s look at how we can run tensorboard in jupyter notebook.
How to run TensorBoard inside Jupyter Notebook?
You need to update your tensorflow and install
tensorflow 2.0.0-aplha0 to run this feature.
# CPU pip install tensorflow==2.0.0-alpha0 # GPU pip install tensorflow-gpu==2.0.0-alpha0
Check what version you have installed:
- Open Command Prompt.
- Run the given command and check the version.
import tensorflow as tf print(tf.__version__)
Install tensorboard-Jupyter Notebook Extension
pip(3) install jupyter-tensorboard
Run Tensorboard inside Jupyter Notebook
You’ll need some test logs that could be visualized in
So just run the test code to create log files.
You can also download the code file from my gihub link.
The test code is given below:
from kaggle_data import load_data, preprocess_data, preprocess_labels import numpy as np import matplotlib.pyplot as plt
X_train, labels = load_data('../data/kaggle_ottogroup/train.csv', train=True) X_train, scaler = preprocess_data(X_train) Y_train, encoder = preprocess_labels(labels) X_test, ids = load_data('../data/kaggle_ottogroup/test.csv', train=False) X_test, _ = preprocess_data(X_test, scaler) nb_classes = Y_train.shape print(nb_classes, 'classes') dims = X_train.shape print(dims, 'dims')
import tensorflow as tf from keras.layers import Dense, Activation
dims = X_train.shape print(dims, 'dims') print("Building model...") nb_classes = Y_train.shape print(nb_classes, 'classes') model = tf.keras.models.Sequential() model.add(tf.keras.layers.Dense(nb_classes, input_shape=(dims,), activation='sigmoid')) model.compile(optimizer = 'sgd', loss='categorical_crossentropy') model.fit(X_train, Y_train, epochs=10, callbacks=[tf.keras.callbacks.TensorBoard('logs')] )
# Load TENSORBOARD %load_ext tensorboard.notebook # Start TENSORBOARD %tensorboard --logdir logs
This should open tensorboard in the same cell.
Best of Luck with your adventures.
If you hit a wall while implementing this post, reach out and comment below.