JupyterLab output doesnt show visualization - spacy

Encountered this issue with 2 different visualization libraries.
PYLDAVIS and DISPLACY (spacy).
On executing a code in jupyterlab (kernel as python3), the output expected should be Jupyter Notebook to show the graph or webcontent. But my Jupyter doesnt show any output with graph / dependency image . I only see textual output in JupyterLab.
eg.
displacy.serve(doc, style='dep')
I'm using KAGGLE docker image which has JUPYTERLAB and on top of that I have updated to latest packages.
Any pointers if this is JUPYTERLAB related or underlying packages?

I can only really comment on the spaCy part of this, but one thing I noticed is that you are using displacy.serve instead of displacy.render, which would be the correct method to call from within a Jupyter environment (see the spaCy visualizer docs for a full example and more details). The reason behind this is that displacy.serve will start a web server to show the visualization in a browser – all of which is not necessary if you're already in a Jupyter Notebook. So when you call displacy.render, it will detect your Jupyter environment, and wrap the visualization accordingly. You can also set jupyter=True to force this behaviour.

try
from spacy import displacy
displacy.render(doc, style="dep", jupyter=True, options={'distance': 140})
or
displacy.render(doc, style="ent", jupyter=True, options={'distance': 140})

Related

I'm having a minor problem running Tensorflow with Colab

I am a beginner who just learned about TensorFlow using Google Colab.
As in the attached image file, numbers 10 to 13 are underlined in tensorflow.keras~, what is the problem?
It's probably a function that indicates a typo, but there's nothing wrong with running it.
enter image description here
This underline error was an ongoing issue earlier in Google Colab, which is resolved now. Please try again replicating the same code in Google colab what you mentioned in the screen shot and let us know if the issue still persists at your end.
Please check the code below: (I replicated the same in Google Colab with python 3.8.10 and TensorFlow 2.9.2)
from keras.preprocessing import Sequence will show the error as you are not giving proper alias to import the Sequence API which is provided correctly in next line (using tensorflow.keras.preprocessing prefix or tensorflow.keras.utils).

Visualize results by Tensorboard

I have a list that each element composed of 4 entries - episode, reward,exploration_rate, and running average. I want to visualize the results by the Tensorboard.
There is some way to visualize these results?
It should be mentioned that I already have the results, so I cant use Callbacks. Currently, I have the results as a Matplotlib plot (Presented in the figure). However, I want to use TensorBoard.
Thanks.
Start by activating your environment in which tensorflow is installed.
conda activate <tensorflow_env>
Then, follow the below command by passing your "log_directory" as the parameter
tensorboard --logdir <log directory>
Kindly follow the link
https://www.tensorflow.org/tensorboard/image_summaries

Extract Grind-Anchors from Object-Detection API Model

I'm currently trying to get my SSDLite Network, which I trained with the Tensroflow Object-detection API working, with iOS.
So I'm using the Open Source Code of SSDMobileNet_CoreML.
The Graph allready works with some limitations. For running on iOS I had to extract the FeatureExtractor from my Graph and where unable to keep Preprocessor, Posprocessor and MutlipleGrindAnchorBox, same as they did in SSDMobileNet_CoreML.
Here you can see the Anchors they have used.
So cause my Anchors seem to be a little different I tried to undestand how they got this array.
So I found in an GitHub Issue an explenation, where the User who created the Anchors explains how he got them.
He says:
I just exported them out of the Tensorflow Graph from the import/MultipleGridAnchorGenerator/Identity tensor
I allready found the matching tensor in my Graph but I don't know how to export the Graph and retrive the correct Anchor encoding.
Can sombody explain this to me?
I allready figured it out. A little below quote was a link to a Python Notebook which explains everything in detail.

Tensorflow object detection API not displaying global steps

I am new here. I recently started working with object detection and decided to use the Tensorflow object detection API. But, when I start training the model, it does not display the global step like it should, although it's still training in the background.
Details:
I am training on a server and accessing it using OpenSSH on Windows. I trained a custom dataset, by collecting pictures and labeling them. I trained it using model_main.py. Also, until a couple of months back, the API was a little different, and only recently they changed to the latest version. For instance, earlier it used to use train.py for training, instead of model_main.py. All the online tutorial I can find use train.py, so it might be a problem with the latest commit. But I don't find anyone else fining this problem.
Thanks in advance!
Add tf.logging.set_verbosity(tf.logging.INFO) after the import section of the model_main.py script. It will display a summary after every 100th step.
As Thommy257 suggested, adding tf.logging.set_verbosity(tf.logging.INFO) after the import section of model_main.py prints the summary after every 100 steps by default.
Further, to specify the frequency of the summary, change
config = tf.estimator.RunConfig(model_dir=FLAGS.model_dir)
to
config = tf.estimator.RunConfig(model_dir=FLAGS.model_dir, log_step_count_steps=k)
where it will print after every k steps.
Regarding the recent change to model_main , the previous version is available at the folder "legacy". I use train.py and eval.py from this legacy folder with the same functionality as before.

Standalone Tensorflow Projector

If you visit the http://projector.tensorflow.org/ you can use it with your own dataset (ie a TSV file). I am playing with N-D data and found useful to look at these visualisations after PCA reduction.
I am wondering how I can run my own Projector version on my machine.
Looking at the doc, it seems to be released only as a tensorboard plugin for seeing the embedding results...
Thanks
According to the replies made on https://github.com/tensorflow/tensorflow/issues/7562 more recently than the other answer here, you can get the standalone version at https://github.com/tensorflow/embedding-projector-standalone/ and edit the oss_demo_projector_config.json to point to your datasets.
The demo files are binary files ending in .bytes, which can be generated from a numpy array with .tofile:
vectors = numpy.zeros(vector_shape, dtype=numpy.float32)
vectors.tofile('my_tensors.bytes')
It has only been released as a TensorBoard plugin.