TypeError:datasetv1adapter不是可呼叫的对象

发布于 2025-02-11 12:46:26 字数 4138 浏览 0 评论 0原文

我的TensorFlow估计器的定义是这样的:

      estimator = tf.estimator.Estimator(
        model_fn=model_fn, 
        model_dir=model_dir, 
        params=None, 
        warm_start_from=warm_start_from,
        config=tf.estimator.RunConfig(
          model_dir=model_dir,
          tf_random_seed=1, 
          save_summary_steps=100,
          save_checkpoints_secs=1600, # 30 minutes      
          session_config=tf.ConfigProto(allow_soft_placement=True, log_device_placement=True),
          # keep_checkpoint_max=5, 
          keep_checkpoint_max=keep_checkpoint_max,
          keep_checkpoint_every_n_hours=10000,
          log_step_count_steps=100, 
          # train_distribute=None, 
          # device_fn=None, 
          # protocol=None,
          # eval_distribute=None, 
          # experimental_distribute=None,
          experimental_max_worker_delay_secs=100, 
          session_creation_timeout_secs=7200
        )
      )

我尝试使用estegator.train(input_fn = triar_input_fn,max_steps = max_steps)在其中:

    train_input_fn : <DatasetV1Adapter shapes: {image: (128, 32, 32, 3), label: (128,)}, types: {image: tf.int32, label: tf.int32}>
    type(train_input_fn) : <class 'tensorflow.python.data.ops.dataset_ops.DatasetV1Adapter'>

错误消息在哪里:错误在哪里:

Traceback (most recent call last):
  File "/usr/lib/python3.8/inspect.py", line 1135, in getfullargspec
    sig = _signature_from_callable(func,
  File "/usr/lib/python3.8/inspect.py", line 2228, in _signature_from_callable
    raise TypeError('{!r} is not a callable object'.format(obj))
TypeError: <DatasetV1Adapter shapes: {image: (128, 32, 32, 3), label: (128,)}, types: {image: tf.int32, label: tf.int32}> is not a callable object

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "scripts/run_cifar.py", line 182, in <module>
    fire.Fire()
  File "/usr/local/lib/python3.8/dist-packages/fire/core.py", line 138, in Fire
    component_trace = _Fire(component, args, parsed_flag_args, context, name)
  File "/usr/local/lib/python3.8/dist-packages/fire/core.py", line 466, in _Fire
    component, remaining_args = _CallAndUpdateTrace(
  File "/usr/local/lib/python3.8/dist-packages/fire/core.py", line 675, in _CallAndUpdateTrace
    component = fn(*varargs, **kwargs)
  File "scripts/run_cifar.py", line 155, in train
    gpu_utils.run_training(
  File "/workspace/diffusion_tf/gpu_utils/gpu_utils.py", line 280, in run_training
    estimator.train(input_fn=train_input_fn, max_steps=max_steps)
  File "/usr/local/lib/python3.8/dist-packages/tensorflow_estimator/python/estimator/estimator.py", line 370, in train
    loss = self._train_model(input_fn, hooks, saving_listeners)
  File "/usr/local/lib/python3.8/dist-packages/tensorflow_estimator/python/estimator/estimator.py", line 1161, in _train_model
    return self._train_model_default(input_fn, hooks, saving_listeners)
  File "/usr/local/lib/python3.8/dist-packages/tensorflow_estimator/python/estimator/estimator.py", line 1187, in _train_model_default
    self._get_features_and_labels_from_input_fn(
  File "/usr/local/lib/python3.8/dist-packages/tensorflow_estimator/python/estimator/estimator.py", line 1025, in _get_features_and_labels_from_input_fn
    self._call_input_fn(input_fn, mode))
  File "/usr/local/lib/python3.8/dist-packages/tensorflow_estimator/python/estimator/estimator.py", line 1103, in _call_input_fn
    input_fn_args = function_utils.fn_args(input_fn)
  File "/usr/local/lib/python3.8/dist-packages/tensorflow_core/python/util/function_utils.py", line 57, in fn_args
    args = tf_inspect.getfullargspec(fn).args
  File "/usr/local/lib/python3.8/dist-packages/tensorflow_core/python/util/tf_inspect.py", line 257, in getfullargspec
    return _getfullargspec(target)
  File "/usr/lib/python3.8/inspect.py", line 1144, in getfullargspec
    raise TypeError('unsupported callable') from ex
TypeError: unsupported callable

错误在哪里:错误?

My TensorFlow estimator is defined like this:

      estimator = tf.estimator.Estimator(
        model_fn=model_fn, 
        model_dir=model_dir, 
        params=None, 
        warm_start_from=warm_start_from,
        config=tf.estimator.RunConfig(
          model_dir=model_dir,
          tf_random_seed=1, 
          save_summary_steps=100,
          save_checkpoints_secs=1600, # 30 minutes      
          session_config=tf.ConfigProto(allow_soft_placement=True, log_device_placement=True),
          # keep_checkpoint_max=5, 
          keep_checkpoint_max=keep_checkpoint_max,
          keep_checkpoint_every_n_hours=10000,
          log_step_count_steps=100, 
          # train_distribute=None, 
          # device_fn=None, 
          # protocol=None,
          # eval_distribute=None, 
          # experimental_distribute=None,
          experimental_max_worker_delay_secs=100, 
          session_creation_timeout_secs=7200
        )
      )

I try to start the training of the estimator with estimator.train(input_fn=train_input_fn, max_steps=max_steps) where:

    train_input_fn : <DatasetV1Adapter shapes: {image: (128, 32, 32, 3), label: (128,)}, types: {image: tf.int32, label: tf.int32}>
    type(train_input_fn) : <class 'tensorflow.python.data.ops.dataset_ops.DatasetV1Adapter'>

The error message is the following:

Traceback (most recent call last):
  File "/usr/lib/python3.8/inspect.py", line 1135, in getfullargspec
    sig = _signature_from_callable(func,
  File "/usr/lib/python3.8/inspect.py", line 2228, in _signature_from_callable
    raise TypeError('{!r} is not a callable object'.format(obj))
TypeError: <DatasetV1Adapter shapes: {image: (128, 32, 32, 3), label: (128,)}, types: {image: tf.int32, label: tf.int32}> is not a callable object

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "scripts/run_cifar.py", line 182, in <module>
    fire.Fire()
  File "/usr/local/lib/python3.8/dist-packages/fire/core.py", line 138, in Fire
    component_trace = _Fire(component, args, parsed_flag_args, context, name)
  File "/usr/local/lib/python3.8/dist-packages/fire/core.py", line 466, in _Fire
    component, remaining_args = _CallAndUpdateTrace(
  File "/usr/local/lib/python3.8/dist-packages/fire/core.py", line 675, in _CallAndUpdateTrace
    component = fn(*varargs, **kwargs)
  File "scripts/run_cifar.py", line 155, in train
    gpu_utils.run_training(
  File "/workspace/diffusion_tf/gpu_utils/gpu_utils.py", line 280, in run_training
    estimator.train(input_fn=train_input_fn, max_steps=max_steps)
  File "/usr/local/lib/python3.8/dist-packages/tensorflow_estimator/python/estimator/estimator.py", line 370, in train
    loss = self._train_model(input_fn, hooks, saving_listeners)
  File "/usr/local/lib/python3.8/dist-packages/tensorflow_estimator/python/estimator/estimator.py", line 1161, in _train_model
    return self._train_model_default(input_fn, hooks, saving_listeners)
  File "/usr/local/lib/python3.8/dist-packages/tensorflow_estimator/python/estimator/estimator.py", line 1187, in _train_model_default
    self._get_features_and_labels_from_input_fn(
  File "/usr/local/lib/python3.8/dist-packages/tensorflow_estimator/python/estimator/estimator.py", line 1025, in _get_features_and_labels_from_input_fn
    self._call_input_fn(input_fn, mode))
  File "/usr/local/lib/python3.8/dist-packages/tensorflow_estimator/python/estimator/estimator.py", line 1103, in _call_input_fn
    input_fn_args = function_utils.fn_args(input_fn)
  File "/usr/local/lib/python3.8/dist-packages/tensorflow_core/python/util/function_utils.py", line 57, in fn_args
    args = tf_inspect.getfullargspec(fn).args
  File "/usr/local/lib/python3.8/dist-packages/tensorflow_core/python/util/tf_inspect.py", line 257, in getfullargspec
    return _getfullargspec(target)
  File "/usr/lib/python3.8/inspect.py", line 1144, in getfullargspec
    raise TypeError('unsupported callable') from ex
TypeError: unsupported callable

Where is the error?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文