Migration of tensorflow python script to 2.1 version - python

I need to migrate some tensorflow scripts to 2.1 version. Reading about this task, I found that one of the main differences is related to tensorflow.contrib that has been removed and replaced as described in this document.
In my scripts, tensorflow.contrib is widely used. Also using indications in the document above, I cannot clearly understand where classes have been moved (e.g. tf.contrib.quantization)
Anyone can help me to understand how locate this library, and more in general libraries that are changed?

Tensorflow migratation guide would be the place where you can start
How to migrate your TensorFlow 1 code to TensorFlow 2

Related

How to import and use metrics in python in the new versions of opentelemetry packages

I'm just starting in telemetry and I got stuck trying to use metrics in the new versions of opentelemetry-api and opentelemetry-sdk.
What I have found
1 - Documentation
This is a old getting started (do not try those scripts, not up to date)
https://open-telemetry.github.io/opentelemetry-python/getting-started.html
And this is the latest getting started
https://opentelemetry-python.readthedocs.io/en/latest/sdk/sdk.html
As you see, in the latest there is no information about metrics just tracing.
2 - The packages
As you see in this image in the version 1.10a0 of the opentelemetry there is the metrics module, while in the current version 1.4 there is no module metrics (see image).
The problem
To use metrics one must run pip install opentelemetry-instumentation-system-metrics by doing this the pip uninstall opentelemetry api and sdk and reinstall old version. (see image). When it happens I am able to import the metrics module, but the tracing does not work anymore.
Question
Where is the metrics module in the new version of opentelemetry?
How can I instrument metrics in the latest version of opentelemetry?
You can't as of now. There is ongoing prototype https://github.com/open-telemetry/opentelemetry-python/pull/1887 for metrics API&SDK based on specification which itself is not stable yet. There is no guaranteed timeline when metrics will be release for end user instrumentation. You may safely assume that it will take few more months to get stable release but there should be alpha-beta release much earlier.

Not able to import from `gensim.summarization` module in Django

I have included the 2 import statements in my views.py
from gensim.summarization.summarizer import summarizer
from gensim.summarization import keywords
However, even after I installed gensim using pip, I am getting the error:
ModuleNotFoundError: No module named 'gensim.summarization'
The summarization code was removed from Gensim 4.0. See:
https://github.com/RaRe-Technologies/gensim/wiki/Migrating-from-Gensim-3.x-to-4#12-removed-gensimsummarization
12. Removed gensim.summarization
Despite its general-sounding name, the module will not satisfy the
majority of use cases in production and is likely to waste people's
time. See this Github
ticket for
more motivation behind this.
If you need it, you could try:
installing the older gensim version; or…
copy the source code out to your own local module
However, I expect you'd likely be disappointed by its inflexibility and how little it can do.
It was only extractive summarization - choosing a few key sentences from those that already exist. That only gives impressive results when the source text was already well-written in an expository style mixing high-level overview sentences with separate detail sentences. And, its method of analyzing/ranking words was very crude & hard-to-customize – totally unconnected to the more generic/configurable/swappable approaches used elsewhere in Gensim or in other text libraries.
You can run pip freeze within your environment to ensure it is installed here.
If it is, then you should check naming of any modules or files you have in your directory to ensure there are no conflicts.
I had the same issue
As per Gensim’s Github changelog 188, gensim.summarization module has been removed in versions Gensim 4.x as it was an unmaintained third-party module.
To continue using gensim.summarization, you will need to downgrade the version of Gensim in the requirements.txt file by replacing it with gensim==3.8.3 or an older version.

ModuleNotFoundError: No module named 'gensim.models.wrappers'

I am trying to use LDA MAllet model. but I am facing with "No module named 'gensim.models.wrappers'" error.
I have gensim installed and ' gensim.models.LdaMulticore' works properly.
Java developer’s kit is installed
I have already downloaded mallet-2.0.8.zip and unzipped it on c:\ drive.
This is the code I am trying to use:
import os
from gensim.models.wrappers import LdaMallet
os.environ.update({'MALLET_HOME':r'C:/mallet-2.0.8/'})
mallet_path = r'C:/mallet-2.0.8/bin/mallet'
Does anyone know what is wrong here? Many thanks!
If you've installed the latest Gensim, 4.0.0 (as of late March, 2021), the LdaMallet model has been removed, along with a number of other tools which simply wrapped external tools/APIs.
You can see the note in the Gensim migration guide at:
https://github.com/RaRe-Technologies/gensim/wiki/Migrating-from-Gensim-3.x-to-4#15-removed-third-party-wrappers
If the use of that tool is essential to your project, you may be able to:
install an older version of Gensim, such as 3.8.3 - though of course you'd then be missing the latest fixes & optimizations on any other Gensim models you're using
extract the ldamallet.py source code from that older version & update/move it to your own code for private use - dealing with whatever issues arise
I had the same issue with Gensim's wrapper for MALLET but didn't want to downgrade. There is this new wrapper that seems to do the job pretty well.
https://github.com/maria-antoniak/little-mallet-wrapper/blob/master/demo.ipynb

Setting up Anaconda to use Tensorboard Profiler

I just installed the tensorboard profiler with
pip install -U tensorboard_plugin_profile
The version is 2.3.
Tensorflow-Version 2.3
Tensorboard-Version 2.3
cudatoolkit-Version 10.1.243
When i now try to open the Profil-Tab in Tensorboard i see the Profiler-Window normaly but empty and the Error-Message:
DEM6561: Failed to load libcupti (is it installed and accessible?)
And the warning:
No step marker observed and hence the step time is unknown. This may happen if (1) training steps are not instrumented (e.g., if you are not using Keras) or (2) the profiling duration is shorter than the step time. For (1), you need to add step instrumentation; for (2), you may try to profile longer.
I think it has something to do with the enviroment-pathes- and variables but i dont know how they work with the virtuel enviroments of Anaconda. (I dont have a Cuda-Folder i can link to)
Had someone the same problem like me or any ideas what i can try?
Thanks ahead!
First, make sure that the CUPTI has been set to Path (via Environment Variables if you're using Windows), adding a path which should look like this:
%CUDA_PATH%\extras\CUPTI\lib64
Second, check if Tensorflow is looking for the correct CUPTI dll. I've encountered this exact same issue and as I checked, it appears that TF 2.4 is looking for cupti64_110.dll instead of cupti64_2020.1.1.dll. It is currently a known issue and will be addressed in TF 2.5. I'm not sure if that's the case too with TF 2.3.
I basically resolved the issue by copying the dll in the same directory and renaming it. Let me know if this helps!

Error in prediction using sknn.mlp

I use Anaconda on a Windows 10 laptop with Python 2.7 and Spark 2.1. Built a deep learning model using Sknn.mlp package. I have completed the model. When I try to predict using the predict function, it throws an error. I run the same code on my Mac and it works just fine. Wondering what is wrong with my windows packages.
'NoneType' object is not callable
I verified input data. It is numpy.array and it does not have null value. Its dimension is same as training one and all attributed are the same. Not sure what it can be.
I don't work with Python on Windows, so this answer will be very vague, but maybe it will guide you in the right direction. Sometimes there are cross-platform errors due to one module still not being updated for the OS, frequently when another related module gets an update. I recall something happened to me with a django application which required somebody more familiar with Windows to fix it for me.
Maybe you could try with an environment using older versions of your modules until you find the culprit.
I finally solved the problem on windows. Here is the solution in case you face it.
The Theano package was faulty. I installed the latest version from github and then it threw another error as below:
RuntimeError: To use MKL 2018 with Theano you MUST set "MKL_THREADING_LAYER=GNU" in your environment.
In order to solve this, I created a variable named MKL_Threading_Layer under user environment variable and passed GNU. Reset the kernel and it was working.
Hope it helps!

Categories