How to use Tensorboard with Tflearn - tensorflow

I am used tflearn
yet I want to use the tensorboard and its visualization
how can I use it?
how to get the session form tflearn?
for example for this example (Pannous speech_data) https://github.com/llSourcell/tensorflow_speech_recognition_demo/blob/master/demo.py

TFLearn supports a verbose level to automatically manage summaries. Setting it to 3 will enable visualization.
Set,
model = tflearn.DNN(net, tensorboard_verbose=3)
You can learn more about it in the Getting started guide.

Related

Saving the Learned Weights of a Network to Train on another Dataset

I would like to train a MLP(Multi Layer Perceptron) with MNIST dataset. I use a validation set so I can save the weights of the best model. Then I want to load these weights back into the same architecture and use them to initialize and train with another dataset. I would like to know if this is possible with Tensorflow 1.x or 2.x. Right now I am trying to write a custom function to do it but it is getting complicated. I am using tf 1.x.
I suggest you take a look at tensorflow's documentation, here a link of a tutorial to save your weights and load them afterwards:
https://www.tensorflow.org/tutorials/keras/save_and_load

How to get hold of graph from tf.function in tensorflow 2.0?

Previously, sess.graph was used as a handle to push things to tensorboard.
There is no current replacement AFAIK. Visualizing graphs is fundamental.
How can we viz graphs in tensorflow 2.0? Must be some hook into the functions.
Tensorboard works in 2.0. This example for keras and this without

Cannot Reload saved Keras model using tensorflow

I am working in a single jupyter notebook. I create and train a very simple CNN with keras. It compiles, fits, and predicts fine. I save it with:
model.save("mymodel.hd5")
Model is a keras.models.Sequential.
I then read that back in with:
reload_keras_model = keras.models.load_model("mymodel.hd5")
That also works fine. However if I try to read the model in using tensorflow via:
from tensorflow.keras.models import load_model
reload_tf_mmodel = load_model("mymodel.hd5")
That fails with:
ValueError: Unknown layer:layers
Most of the threads I've read on github say "update your model" or comments about custom objects (I'm not using any). My target platform is the rpi zero and I've been able to install tf but unable to install keras, and that's why I want to load via tf. Why would keras and tf.keras handle this model differently and what do I need to update/change to read it in with tf.keras?
While keras (can) use TF as Backend, it does not guarantee that the saved model is readable in TF as well.
Note that you can use keras with both theano and tf, thus reload_keras_model = keras.models.load_model("mymodel.hd5") will work good with both backends, as the saving/loading is done in the "keras" part, and not using the backend.
You can use this tool: keras_to_tensorflow
Or something similar.

Is it possible to make tensorflow graph summary?

I'm aware of Tensorboard and how awesome it is, but I think that simple console output with current graph summary is better (and faster) for prototyping purpose.
And also know that I can generate tensorboard graph after simply running session with last network node as shown here.
What I'm looking for is something similar to model.summary() from Keras.
In another words: how to iterate over tensorflow graph and print out only custom high end layer with their shapes and dtypes in the same order how all these layer where generated?
It's certainly possible. If you are using tf.keras wrapper to build you can easily visualize the graph, even before model.compile() method executes.
It's keras built-in functionality called plot_model().
*This method have dependency on graphviz and pydot libraries.
for pydot installation : pip install pydot
but for graphviz installation you have follow step in this page. And also probably you have to restart the machine because of there it create system environment variables.
for tutorial on how to use this method follow this link
To plot your model with shapes and dtypes before training you could use:
tf.keras.utils.plot_model(model, show_shapes=True, expand_nested=True, show_dtype=True)
where "model" is your built model. The output of a model could looks like this:

Tensorflow, equivalent of Theano's pydotprint?

In Theano, I can use pydotprint to generate a nice graph of my model. Very useful for debugging, and for presenting too. Is there an equivalent for TensorFlow?
As #JHafdahl points out, TensorBoard provides graph visualization for TensorFlow graphs, which includes support for summarizing complex nested subgraphs.
To visualize a graph, build a TensorFlow graph as normal, then add the following statements to your Python program:
writer = tf.train.SummaryWriter("/path/to/logs", tf.get_default_graph().as_graph_def())
writer.flush()
Then, in a separate terminal, run TensorBoard to visualize your graph:
$ tensorboard --logdir=/path/to/logs --port 6006
Finally, connect to TensorBoard by opening http://localhost:6006 in your web browser. Clicking on the "Graph" tab will show the visualization of your graph; see the graph visualization tutorial for more details.
Look into Tensorboard, which ships with Tensorflow. I use it to track the performance of my models and make sure they are converging.