Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AttributeError: module 'tensorflow._api.v1.compat.v1.compat' has no attribute 'v1 #1802

Open
Fady-Wasfalla opened this issue Mar 21, 2020 · 0 comments

Comments

@Fady-Wasfalla
Copy link

@Fady-Wasfalla Fady-Wasfalla commented Mar 21, 2020

Description

I am using tensot2tensor which is built over Tensorflow and when I reach to the step pf training I got this error AttributeError: module 'tensorflow._api.v1.compat.v1.compat' has no attribute 'v1 and here is my code on google colab
...
!git clone https://github.com/tensorflow/tensor2tensor.git

import os
os.chdir('tensor2tensor')
!ls
!pip install .

import tensorflow as tf
import os
os.mkdir("/content/t2t")
os.mkdir("/content/t2t/data")
os.mkdir("/content/t2t/tmp")
os.mkdir("/content/t2t/train")
os.mkdir("/content/t2t/export")
os.mkdir("/content/t2t/translation")
os.mkdir("/content/t2t/event")
os.mkdir("/content/t2t/user")

DATA_DIR = "/content/t2t/data"
TMP_DIR = "/content/t2t/tmp"
TRAIN_DIR = "/content/t2t/train"
EXPORT_DIR = "/content/t2t/export"
TRANSLATIONS_DIR = "/content/t2t/translation"
EVENT_DIR = "/content/t2t/event"
USR_DIR = "/content/t2t/user"

PROBLEM = "translate_enfr_wmt_small8k" # We chose a problem translation English to French with 32.768 vocabulary
MODEL = "transformer" # Our model
HPARAMS = "transformer_big_single_gpu" # Hyperparameters for the model by default
# If you have a one gpu, use transformer_big_single_gpu

!t2t-datagen
--data_dir=$DATA_DIR
--tmp_dir=$TMP_DIR
--problem=$PROBLEM
--t2t_usr_dir=$USR_DIR

train_steps = 300000 # Total number of train steps for all Epochs
eval_steps = 100 # Number of steps to perform for each evaluation
batch_size = 4096
save_checkpoints_steps = 1000
ALPHA = 0.1
schedule = "continuous_train_and_eval"

!t2t-trainer
--data_dir=$DATA_DIR
--problem=$PROBLEM
--model=$MODEL
--hparams_set=$HPARAMS
--hparams="batch_size=$batch_size"
--schedule=$schedule
--output_dir=$TRAIN_DIR
--train_steps=$train_steps
--worker-gpu=1 \

OS: <your answer here>

$ pip freeze | grep tensor
# your output here

$ python -V
# your output here

For bugs: reproduction and error logs

# Steps to reproduce:
...
# Error logs:
...
AttributeError: in converted code:

    /usr/local/lib/python3.6/dist-packages/tensor2tensor/utils/t2t_model.py:323 call  *
        summarize_features(features, num_shards=self._num_datashards)
    /usr/local/lib/python3.6/dist-packages/tensor2tensor/utils/t2t_model.py:2240 summarize_features  *
        if not common_layers.should_generate_summaries():
    /usr/local/lib/python3.6/dist-packages/tensor2tensor/layers/common_layers.py:3494 should_generate_summaries  *
        if tf.compat.v1.get_variable_scope().reuse:
    /tensorflow-1.15.0/python3.6/tensorflow_core/python/util/module_wrapper.py:193 __getattr__
        attr = getattr(self._tfmw_wrapped_module, name)

    AttributeError: module 'tensorflow._api.v1.compat.v1.compat' has no attribute 'v1'
EmilsOzolins added a commit to LUMII-Syslab/tensor2tensor that referenced this issue Apr 21, 2020
tensorflow._api.v1.compat.v1.compat' has no attribute 'v1.
tf already imported as tf.compat.v1 and there is
no need to use it explicitly.
afrozenator pushed a commit that referenced this issue Jun 16, 2020
* Fix issue #1802

tensorflow._api.v1.compat.v1.compat' has no attribute 'v1.
tf already imported as tf.compat.v1 and there is
no need to use it explicitly.

* T2T implementation of Residual Shuffle-Exchange networks.

Publication: https://arxiv.org/abs/2004.04662
Original code: https://github.com/LUMII-Syslab/RSE
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
1 participant
You can’t perform that action at this time.