class TPUEstimator(Estimator, tf.compat.v1.estimator.tpu.TPUEstimator):
AttributeError: module 'tensorflow._api.v2.compat.v2.compat' has no attribute 'v1'
Traceback (most recent call last):
File "train.py", line 51, in <module>
from builders import model_builder
File "C:\tensorflow1\models\research\object_detection\builders\model_builder.py", line 35, in <module>
from object_detection.models import faster_rcnn_inception_resnet_v2_feature_extractor as frcnn_inc_res
File "C:\tensorflow1\models\research\object_detection\models\faster_rcnn_inception_resnet_v2_feature_extractor.py", line 29, in <module>
from nets import inception_resnet_v2
File "C:\tensorflow1\models\research\slim\nets\inception_resnet_v2.py", line 373, in <module>
batch_norm_updates_collections=tf.compat.v1.GraphKey.UPDATE_OPS,
AttributeError: module 'tensorflow._api.v1.compat.v1' has no attribute 'GraphKey'
the code are def inception_resnet_v2_arg_scope(
weight_decay=0.00004,
batch_norm_decay=0.9997,
batch_norm_epsilon=0.001,
activation_fn=tf.nn.relu,
batch_norm_updates_collections=tf.compat.v1.GraphKey.UPDATE_OPS,
batch_norm_scale=False):
I have a tf.data.Dataset and an input_fn that returns that dataset. I get a "input_fn" not callable error. But this approach is documented in the tensorflow docs. Can anyone help?
I may have resolved this (peculiarity of estimator API, input_fn must be argument-free) but there is a problem
Hi there,
I just converted an existing project from TF 1.14 to TF 2.1 (both having version 0.8.0 of Adanet installed) using adanet.TPUEstimator. After making the switch, testing locally on CPU with use_tpu=False runs successfully. However, I am getting errors when running on TPU (i.e. use_tpu=True). The errors appear to originate in the tpu_estimator.py and error_handling.py scripts seen in the Traceback below:
```File "/usr/local/lib/python3.6/site-packages/tensorflow_estimator/python/estimator/tpu/tpu_estimator.py", line 3032, in train
rendezvous.record_error('training_loop', sys.exc_info())
File "/usr/local/lib/python3.6/site-packages/tensorflow_estimator/python/estimator/tpu/error_handling.py", line 81, in record_error
if value and value.op and value.op.type == _CHECK_NUMERIC_OP_NAME:
AttributeError: 'RuntimeError' object has no attribute 'op'
During handling of the above exception, another exception occurred:
File "workspace/trainer/train.py", line 331, in <module>
main(args=parsed_args)
File "workspace/trainer/train.py", line 177, in main
run_config=run_config)
File "workspace/trainer/train.py", line 68, in run_experiment
estimator.train(input_fn=train_input_fn, max_steps=total_train_steps)
File "/usr/local/lib/python3.6/site-packages/adanet/core/estimator.py", line 853, in train
saving_listeners=saving_listeners)
File "/usr/local/lib/python3.6/site-packages/tensorflow_estimator/python/estimator/tpu/tpu_estimator.py", line 3035, in train
rendezvous.raise_errors()
File "/usr/local/lib/python3.6/site-packages/tensorflow_estimator/python/estimator/tpu/error_handling.py", line 143, in raise_errors
six.reraise(typ, value, traceback)
File "/usr/local/lib/python3.6/site-packages/six.py", line 703, in reraise
raise value
File "/usr/local/lib/python3.6/site-packages/tensorflow_estimator/python/estimator/tpu/tpu_estimator.py", line 3030, in train
saving_listeners=saving_listeners)
File "/usr/local/lib/python3.6/site-packages/tensorflow_estimator/python/estimator/estimator.py", line 374, in train
loss = self._train_model(input_fn, hooks, saving_listeners)
File "/usr/local/lib/python3.6/site-packages/tensorflow_estimator/python/estimator/estimator.py", line 1164, in _train_model
return self._train_model_default(input_fn, hooks, saving_listeners)
File "/usr/local/lib/python3.6/site-packages/tensorflow_estimator/python/estimator/estimator.py", line 1194, in _train_model_default
features, labels, ModeKeys.TRAIN, self.config)
File "/usr/local/lib/python3.6/site-packages/tensorflow_estimator/python/estimator/tpu/tpu_estimator.py", line 2857, in _call_model_fn
config)
File "/usr/local/lib/python3.6/site-packages/tensorflow_estimator/python/estimator/estimator.py", line 1152, in _call_model_fn
model_fn_results = self._model_fn(features=features, **kwargs)
File "/usr/local/lib/python3.6/site-packages/tensorflow_estimator/python/estimator/tpu/tpu_estimator.py", line 3186, in _model_fn
host_ops = host_call.create_tpu_hostcall()
File "/usr/local/lib/python3.6/site-packages/tensorflow_estimator/python/estimator/tpu/tpu_estimator.py", line 2226, in create_tpu_hostcall
'dimension, but got scalar {}'.format(dequeue_ops[i][0]))
RuntimeError: All tensors outfed from TPU should preserve batch size dimension, but got scalar Tensor("OutfeedDequeueTuple:1", shape=(), dtype=int64, device=/job:tpu_worker/task:0/device:CPU:0)
'''
The previous version of the project using TF 1.14 and Adanet 0.8.0 runs both locally and on TPU using adanet.TPUEstimator without issues. Is there something obvious I am potentially missing for the switch over to TF 2.1 when using TPUEstimator?