1

我正在使用基于 Tensorflow 构建的 tensot2tensor,当我到达训练 pf 步骤时,出现此错误 AttributeError: module 'tensorflow._api.v1.compat.v1.compat' has no attribute 'v1 and here is my code on google合作实验室

!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 \ 
4

0 回答 0