I am getting this error AttributeError: module 'torch' has no attribute 'linalg' when updating the parameters using optimizer.step(model.closure).
I am using Pytorch version 1.4.0.
linalg was introduced to pytorch only on a later version (1.7.0). Update pytorch and try again.
Related
AttributeError: module 'numpy' has no attribute 'object'
enter image description here
I tried reinstall numpy, and importing numpy with path
numpy.object was deprecated in version 1.20.0. You can use np.object_ instead.
From your screenshot, it looks like it is tensorflow which is referencing np.object; in this case you should either update tensorflow to a newer version that is compatible with numpy 1.20, or downgrade numpy to version 1.19 or older so it works with your tensorflow installation.
My code is as follows:
!pip install flax
init_params = TransporterNets().init(key, init_img, init_text, init_pix)['params']
print(f'Model parameters: {n_params(init_params):,}')
optim = flax.optim.Adam(lr=1e-4).create(init_params)
However it shows the following error:
AttributeError: module 'flax' has no attribute 'optim'
Even though I have seen documentation of optim attribute in flax module. How to fix it?
You can temporarily solve the issue by downgrading flax version from 0.6.0 to 0.5.1 at the moment.
pip install flax==0.5.1
I tried to run the https://github.com/4Catalyzer/cyclegan.git
I have error like
AttributeError: module 'tensorflow._api.v2.train' has no attribute 'string_input_producer'
I use python 3.8.5 and tensorflow 2.4.1
tf.compat.v1.train.string_input_producer is deprecated in. It will be removed in a future version. Instructions for updating: Queue-based input pipelines have been replaced by tf.data.
Use tf.data.Dataset.from_tensor_slices(string_tensor).
shuffle(tf.shape(input_tensor, out_type=tf.int64)[0]).repeat(num_epochs). If shuffle=False, omit the .shuffle(...)
code:
init = tf.initialize_all_variables()
init = tf.global_variables_initializer()
error:
module 'tensorflow' has no attribute 'initialize_all_variables'
module 'tensorflow' has no attribute 'global_variables_initializer'
There is no tf.initialize_all_variables or tf.global_variables_initializer in TF2. See the guide: Migrate your TensorFlow 1 code to TensorFlow 2
If you want to use TF1 behavior in TF2, you can use the tf.compat.v1 module.
I am trying to use the object detection tutorial from tensor flow api. I am using python 3 and tensor flow version 2. But getting the below error.I tried several ways:
File "C:\Aniruddhya\object_detection\object_detection\utils\label_map_util.py", line 137, in load_labelmap
with tf.gfile.GFile(path, 'r') as fid:
AttributeError: module 'tensorflow' has no attribute 'gfile'
can someone help me to run this?
code link: https://drive.google.com/drive/u/3/folders/1XHpnr5rsENzOOSzoWNTvRqhEbLKXaenL
It's not called that in TensorFlow 2. You might be using a TensorFlow 1 tutorial.
Version 1
tf.gfile.GFile
https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/io/gfile/GFile
Version 2
tf.io.gfile.GFile
https://www.tensorflow.org/api_docs/python/tf/io/gfile/GFile
If you have Tensorflow version 2. You can use the next module compatible with the version 1, too.
import tensorflow.compat.v1 as tf
I solved this problem by reinstalling tensor using the previous version: sudo pip3 install tensorflow==1.14.0
You may optionally downgrade to previous version of tensorflow:
!pip install tensorflow==1.12.0
import tensorflow as tf
print(tf.__version__)
otherwise , make if tf.io.gfile and import tf.io