Tensorflow set_seed error when running autoencoder - tensorflow

I am trying to run the code from here,
https://medium.com/#abien.agarap/implementing-an-autoencoder-in-tensorflow-2-0-5e86126e9f7
but am getting this error,
File
"C:/Users/rupert/Versioning/PCTSoftware/Libraries/python/tensorflow/autoencoders/autoencoder-full.py",
line 12, in
tf.random.set_seed(1)
AttributeError: module 'tensorflow._api.v1.random' has no attribute
'set_seed'
Any ideas on how to resolve?
Tensorflow 1.13
Windows 7

Try this:
tf.random.set_random_seed(1)

As you can see, the post is focusing on the version 2.0.0 of tensorflow. You should run their code with their version.

Related

ValueError: GRU(reset_after=False) is not compatible with GRU(reset_after=True)

How to solve this error which is raised when loading the weights from h5 file?
ValueError: GRU(reset_after=False) is not compatible with
GRU(reset_after=True)
Github link : https://github.com/emilwallner/Screenshot-to-code
Colab link : https://colab.research.google.com/drive/106_QEi_Wp6mfDDE1E2lPSPh7S9CABk6B#revisionId=0Byh7i7xj0YHlMU0xaTJCWDA3ZzZNTlA1VFFRWU5xQWdtc2tFPQ
dataset drive link:
https://drive.google.com/drive/folders/1BTeUbXO7qBvOT4VkhOrr7SOcSocSZyeb?usp=sharing
set reset_after=True in your GRU layer
Probably the version of the TensorFlow is not compatible with other packages. Try using Tensorflow==1.15.0. You can install it by writing pip install TensorFlow==1.15.0

Gradient Boosting classifier issue

I am getting crazy trying to fix the issue of "name 'XGBClassifier' is not defined".
Any clue please?
My environment is Win 64, Python 3.7
This can be very open ended issue. I would suggest you to check if Xgboost is imported or not , if not imported than is there any installation issue or not-
try:
import xgboost
except ImportError:
pass
except:
print("xgboost is installed...but failed to load!")
pass
Other points to be consider,
Try to work in virtual environment which can exempt the other packages conflict with xgboost version.
Check the Input shape - there are times when this is the root cause of issue.

How to convert Onnx model (.onnx) to Tensorflow (.pb) model

I am trying to convert .onxx model to .pb model. I have written the code but i am getting error:
#tf_func(tf.ceil)AttributeError: module 'tensorflow' has no attribute 'ceil'
Code:
import onnx
from tensorflow.python.tools.import_pb_to_tensorboard import import_to_tensorboard
from onnx_tf.backend import prepare
onnx_model = onnx.load("original_3dlm.onnx")
tf_rep = prepare(onnx_model)
tf_rep.export_graph("model_var.pb")
import_to_tensorboard("model_var.pb", "tb_log")
How to resolve this issue? Is there any other way to convert Onxx to Tensorflow?
I solve this issue with this.
Tensorflow Backend for ONNX.
Let me know if you have any issue.
Change from tensorflow 2.0 to 1.14.Maybe solve the problem.
your code as far as I can tell should be fine. The problem probably lies in the onnx-tf version you currently use. pip currently installs a version that only supports TensorFlow <= 1.15.
run this in the terminal to install a more up-to-date version of onnx-tf.
pip uninstall onnx_tf
pip install git+https://github.com/onnx/onnx-tensorflow.git
refer to this issue for further details

AttributeError: module 'tensorflow.estimator' has no attribute 'SessionRunHook'

I'm running TensorFlow version 1.9 on Ubuntu 18. I am trying to use tensorboard visualization .
I have installed tensorboard 1.9 with my anaconda prompt.
I have excuted this command :
tensorboard --logdir=./eval/ --port=8090 --host=127.0.0.1
eval is the file that contains summary data that i have generated when running TensorFlow .
The script fails with:
File "/home/anaconda3/envs/tensorflow_cpu/bin/tensorboard", line 7, in
from tensorboard.main import run_main
File "/home/anaconda3/envs/tensorflow_cpu/lib/python3.6/site-packages/tensorboard/main.py", line 44, in
from tensorboard import default
File "/home/anaconda3/envs/tensorflow_cpu/lib/python3.6/site-packages/tensorboard/default.py", line 36, in
from tensorboard.plugins.beholder import beholder_plugin
File "/home/anaconda3/envs/tensorflow_cpu/lib/python3.6/site-packages/tensorboard/plugins/beholder/__init__.py", line 15, in
from tensorboard.plugins.beholder.beholder import Beholder
File "/home/anaconda3/envs/tensorflow_cpu/lib/python3.6/site-packages/tensorboard/plugins/beholder/beholder.py", line 199, in
class BeholderHook(tf.estimator.SessionRunHook):
AttributeError: module 'tensorflow.estimator' has no attribute 'SessionRunHook'
Please could someone help me find the solution to this error?
Thank you
This might be caused due to 2 reasons:
inconsistency in versions between your Tensorflow and Tensosrboard.
if your tensorflow version is less than 1.10
Try to upgrade the versions of Tensorflow and Tensorboard so that the corresponding versions are greater than 1.12 and make sure the versions are consistent with each other. This should solve your problem.
For more information, you can refer to the following issues [1] and [2]

module 'tensorflow' has no attribute 'logging'

I'm trying to run a tensorflow code in v2.0 and I'mg getting the following error
AttributeError: module 'tensorflow' has no attribute 'logging'
I don't want to simply remove it from the code.
why this code has been removed?
why should I do instead?
tf.logging was for Logging and Summary Operations and in TF 2.0 it has been removed in favor of the open-source absl-py, and to make the main tf.* namespace has functions that will be used more often.
In TF.2 lesser used functions are gone or moved into sub-packages like tf.math
So instead of tf.logging you could:
tf_upgrade_v2 will upgrade script and changes tf.logging to tf.compat.v1.logging
Python logging module can be used instead
Import absl-py library
If you are using someone else's code it's better to install same Tensorflow version as the author used, or downgrade your Tensorflow version. You may wanna try this:
pip install tensorflow==1.15.0
Or if you have gpu:
pip install tensorflow-gpu==1.15.0
You may still get depricated warnings, however you don't need to modify several files replacing tf with tf.compat.v1