No Attribute 'do_not_convert' found while importing onnx_tf - tensorflow

I'm trying to convert Pytorch model into Tensorflow model using ONNX, but I'm getting the following error while importing onnx_tf library.
AttributeError: module 'tensorflow._api.v1.autograph.experimental' has no attribute 'do_not_convert'
I did check the documentations and other forums, didn't get a clear solution.
I'm using the following versions:
onnx==1.13.0
onnx-tf==1.10.0
torch==1.13.0
tensorflow==1.13.1
Help me understand this issue and find a working solution.

Related

Unexpected keyword argument 'show_dtype'

I am trying to plot my model with the data types with the following the code:
plot_model(model, to_file='model/model.png', show_dtype=True, show_shapes=True, show_layer_names=True)
However, I get an error that show_dtype is not an acceptable parameter even though it appears on the TensorFlow documentation: https://www.tensorflow.org/api_docs/python/tf/keras/utils/plot_model
This is the first time that I have run into this issue. It seems that this may be due to having an earlier release if you downloaded it from Anaconda Forge rather than something else like Pip. It is a simple fix, however.
Basically, you need to go into the library source file and edit it to the current version that is shown on the TensorFlow documentation page.
The link to the GitHub page that you will copy the Python code from is here: https://github.com/tensorflow/tensorflow/blob/v2.5.0/tensorflow/python/keras/utils/vis_utils.py#L278-L348
Afterwards, head to your library path and paste that Python code there.
For example, my path is the following: C:/ProgramData/Anaconda3/envs/ml/Lib/site-packages/tensorflow/python/keras/utils/vis_utils.py. Yours should be something similar.

Error using update_struct function in TensorFlow Federated

I'm attempting to run the Minimal Stand-Alone Implementation of Federated Averaging from the TensorFlow Federated GitHub repository but receiving the following error in the server_update function:
AttributeError: module 'tensorflow_federated.python.common_libs.structure' has no attribute 'update_struct'
I have some old TensorFlow Federated code that uses the update_state function from the tff.utils package in place of update_struct() but according to a commit on GitHub this package is empty now. I'm using TensorFlow Federated version 0.18.0 and I also had the same problem trying on Google CoLab.
My question is how can I fix this error?
Thanks, any help appreciated.
I am assuming you hit the error you describe here.
It seems that the symbol is not in the 0.18 release. You can either depend on the nightly version (pip install tensorflow-federated-nightly), or modify the line to construct the new object directly, instead of using the update_struct helper. That is, the linked command could change to:
return ServerState(model_weights,
server_optimizer.variables(),
server_state.round_num + 1))

module 'trax.supervised' has no attribute 'inputs'

I am working on a project involving Google's TRAX package. I encountered the following error message while running a snippet of code on Jupyter notebook.
module 'trax.supervised' has no attribute 'inputs'
Is there a way around this issue? I have trax version 1.2.3.
Thanks!
As per trax documentation
The call must be trax.data rather than trax.Supervised
trax.data.inputs.add_loss_weights(generator, id_to_mask=None)
https://trax-ml.readthedocs.io/en/latest/trax.data.html

compiling inception_client.cc without bazel

I need a simple function for my c++ program to be able to pull predictions from the tensorflow model server so I decided to user the inception client as a starting point.
I've followed the advice from here:
https://github.com/tensorflow/tensorflow/issues/2412
I'm currently getting various compile errors such as:
"undefined reference to tensorflow::serving::PredictRequest::_slow_mutable_model_spec()" and "undefined reference to tensorflow::serving::PredictRequest::~PredictRequest()"
Am I missing a library or something.
Is there a simpler way to make the function without the need for tensorflow in c++?

Did tensorflow at any point change 'tensorflow.sub' into 'tensorflow.subtract'?

I was testing some code I was given and got an error saying:
AttributeError: 'module' object has no attribute 'sub'
The module referred to is TensorFlow. To investigate this error I started looking into the TensorFlow source code and found a function 'tensorflow.subtract'. Replacing 'sub' by 'subtract' made the error go away.
However now I am still wondering why the error occurred in the first place. I can think of 2 reasons:
At some point TensorFlow renamed 'sub' to 'subtract' and the code I was given hasn't yet updated to accommodate that change. Changing 'sub' to 'subtract' simply updated the code to the newer version of TensorFlow
I have made some mistake in importing the wrong libraries and TensorFlow does actually have a 'sub' function. This would mean that changing to 'subtract' potentially altered the workings of the program.
Can anyone give advice on what the most likely scenario is here?
The TensorFlow 1.0 release contained multiple breaking changes to the API, including the renaming of tf.sub to tf.subtract (likewise, tf.mul was renamed to tf.multiply et cetera). Comprehensive lists of all changes can be found here:
https://www.tensorflow.org/install/migration
https://github.com/tensorflow/tensorflow/releases/tag/v1.0.0