train_and_eval mode error after first epoch
I'm trying to make work the "Finetune on PASCAL VOC 2012 with detector COCO ckpt." part. I decided to use efficientdet-d1 checkpoint and the model learns through the first epoch without any problem. My command:
python main.py --mode=train_and_eval \
--num_classes=20 \
--training_file_pattern=tfrecord/pascal_*.tfrecord \
--validation_file_pattern=tfrecord/pascal*.tfrecord \
--val_json_file=tfrecord/json_pascal.json \
--model_name=efficientdet-d1 \
--model_dir=tmp/efficientdet-d1 \
--ckpt=tmp/ckpt/efficientdet-d1 \
--train_batch_size=4 \
--eval_batch_size=4 --eval_samples=1024 \
--num_examples_per_epoch=5717 --num_epochs=10 \
--hparams="use_bfloat16=false,num_classes=20,moving_average_decay=0" \
--use_tpu=False
After the first epoch, when it starts to evaluate, I got an error:
File "/home/babicdo/.virtualenvs/efficientdet/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 "/home/babicdo/.virtualenvs/efficientdet/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: 'ValueError' object has no attribute 'op'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "main.py", line 390, in <module>
tf.app.run(main)
File "/home/babicdo/.virtualenvs/efficientdet/lib/python3.6/site-packages/tensorflow_core/python/platform/app.py", line 40, in run
_run(main=main, argv=argv, flags_parser=_parse_flags_tolerate_undef)
File "/home/babicdo/.virtualenvs/efficientdet/lib/python3.6/site-packages/absl/app.py", line 299, in run
_run_main(main, args)
File "/home/babicdo/.virtualenvs/efficientdet/lib/python3.6/site-packages/absl/app.py", line 250, in _run_main
sys.exit(main(argv))
File "main.py", line 358, in main
steps=int(FLAGS.num_examples_per_epoch / FLAGS.train_batch_size))
File "/home/babicdo/.virtualenvs/efficientdet/lib/python3.6/site-packages/tensorflow_estimator/python/estimator/tpu/tpu_estimator.py", line 3035, in train
rendezvous.raise_errors()
File "/home/babicdo/.virtualenvs/efficientdet/lib/python3.6/site-packages/tensorflow_estimator/python/estimator/tpu/error_handling.py", line 143, in raise_errors
six.reraise(typ, value, traceback)
File "/home/babicdo/.virtualenvs/efficientdet/lib/python3.6/site-packages/six.py", line 703, in reraise
raise value
File "/home/babicdo/.virtualenvs/efficientdet/lib/python3.6/site-packages/tensorflow_estimator/python/estimator/tpu/tpu_estimator.py", line 3030, in train
saving_listeners=saving_listeners)
File "/home/babicdo/.virtualenvs/efficientdet/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 "/home/babicdo/.virtualenvs/efficientdet/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 "/home/babicdo/.virtualenvs/efficientdet/lib/python3.6/site-packages/tensorflow_estimator/python/estimator/estimator.py", line 1194, in _train_model_default
features, labels, ModeKeys.TRAIN, self.config)
File "/home/babicdo/.virtualenvs/efficientdet/lib/python3.6/site-packages/tensorflow_estimator/python/estimator/tpu/tpu_estimator.py", line 2857, in _call_model_fn
config)
File "/home/babicdo/.virtualenvs/efficientdet/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 "/home/babicdo/.virtualenvs/efficientdet/lib/python3.6/site-packages/tensorflow_estimator/python/estimator/tpu/tpu_estimator.py", line 3126, in _model_fn
features, labels, is_export_mode=is_export_mode)
File "/home/babicdo/.virtualenvs/efficientdet/lib/python3.6/site-packages/tensorflow_estimator/python/estimator/tpu/tpu_estimator.py", line 1663, in call_without_tpu
return self._call_model_fn(features, labels, is_export_mode=is_export_mode)
File "/home/babicdo/.virtualenvs/efficientdet/lib/python3.6/site-packages/tensorflow_estimator/python/estimator/tpu/tpu_estimator.py", line 2005, in _call_model_fn
return estimator_spec.as_estimator_spec()
File "/home/babicdo/.virtualenvs/efficientdet/lib/python3.6/site-packages/tensorflow_estimator/python/estimator/tpu/tpu_estimator.py", line 379, in as_estimator_spec
host_call_ret = _OutfeedHostCall.create_cpu_hostcall(host_calls)
File "/home/babicdo/.virtualenvs/efficientdet/lib/python3.6/site-packages/tensorflow_estimator/python/estimator/tpu/tpu_estimator.py", line 2076, in create_cpu_hostcall
ret[name] = host_fn(*tensors)
File "/home/babicdo/Work/automl/efficientdet/utils.py", line 346, in host_call_fn
tf2.summary.scalar(name, tensor, step=gs)
File "/home/babicdo/.virtualenvs/efficientdet/lib/python3.6/site-packages/tensorboard/plugins/scalar/summary_v2.py", line 60, in scalar
name, 'scalar_summary', values=[data, step]) as (tag, _):
File "/usr/lib/python3.6/contextlib.py", line 81, in __enter__
return next(self.gen)
File "/home/babicdo/.virtualenvs/efficientdet/lib/python3.6/site-packages/tensorflow_core/python/ops/summary_ops_v2.py", line 603, in summary_scope
with ops.name_scope(name, default_name, values) as scope:
File "/home/babicdo/.virtualenvs/efficientdet/lib/python3.6/site-packages/tensorflow_core/python/framework/ops.py", line 6237, in __enter__
g_from_inputs = _get_graph_from_inputs(self._values)
File "/home/babicdo/.virtualenvs/efficientdet/lib/python3.6/site-packages/tensorflow_core/python/framework/ops.py", line 5883, in _get_graph_from_inputs
_assert_same_graph(original_graph_element, graph_element)
File "/home/babicdo/.virtualenvs/efficientdet/lib/python3.6/site-packages/tensorflow_core/python/framework/ops.py", line 5818, in _assert_same_graph
(item, original_item))
ValueError: Tensor("strided_slice:0", shape=(), dtype=int64) must be from the same graph as Tensor("strided_slice_8:0", shape=(), dtype=float32).
I even commented out the eval part so only the training should run through the epochs, but I got the same error. I suspect there might be a problem with loading the weights from the checkpoint, but I really don't know how to fix it. Should I not exclude the vars that are excluded by default from the uploaded checkpoint?
Sorrry, I made a mistake in previous commit. Now it is fixed in https://github.com/google/automl/commit/a365054dd3b57d1609660817855b99b50ec63412
I have verified it works well now.