tensorflow 1.5 TypeError: __init__() got an unexpected keyword argument 'dct_method'

在运行 objection_detection 下的train进行训练的时候报错 如下:

D:\software\Anaconda\envs\py3\python.exe E:/tensorflow-relevant-download/light_dection/object_detection/train.py --logtostderr --pipeline_config_path=../models/model/ssd_mobilenet_v1_pets.config --train_dir=../models/model/train
WARNING:tensorflow:From E:\tensorflow-relevant-download\light_dection\object_detection\trainer.py:228: create_global_step (from tensorflow.contrib.framework.python.ops.variables) is deprecated and will be removed in a future version.
Instructions for updating:
Please switch to tf.train.create_global_step
Traceback (most recent call last):
  File "E:/tensorflow-relevant-download/light_dection/object_detection/train.py", line 155, in <module>
    tf.app.run()
  File "D:\software\Anaconda\envs\py3\lib\site-packages\tensorflow\python\platform\app.py", line 124, in run
    _sys.exit(main(argv))
  File "E:/tensorflow-relevant-download/light_dection/object_detection/train.py", line 151, in main
    worker_job_name, is_chief, FLAGS.train_dir)
  File "E:\tensorflow-relevant-download\light_dection\object_detection\trainer.py", line 235, in train
    train_config.prefetch_queue_capacity, data_augmentation_options)
  File "E:\tensorflow-relevant-download\light_dection\object_detection\trainer.py", line 59, in create_input_queue
    tensor_dict = create_tensor_dict_fn()
  File "E:/tensorflow-relevant-download/light_dection/object_detection/train.py", line 108, in get_next
    dataset_builder.build(config)).get_next()
  File "E:\tensorflow-relevant-download\light_dection\object_detection\builders\dataset_builder.py", line 138, in build
    label_map_proto_file=label_map_proto_file)
  File "E:\tensorflow-relevant-download\light_dection\object_detection\data_decoders\tf_example_decoder.py", line 110, in __init__
    dct_method=dct_method),
TypeError: __init__() got an unexpected keyword argument 'dct_method'

Process finished with exit code 1

stack overflow 提到解决方案 https://stackoverflow.com/questions/48920762/tensorflow-error-typeerror-init-got-an-unexpected-keyword-argument-dct

tensorflow issue也再次提到.https://github.com/tensorflow/models/issues/3421

具体解决方案如下

This error is due to the incompatibility of file tf_example_decoder.py with the Tensorflow installed.

In file models/research/object_detection/data_decoders/tf_example_decoder.py:

line 28:

slim_example_decoder = tf.contrib.slim.tfexample_decoder
line 104:

self.items_to_handlers = {
fields.InputDataFields.image:
slim_example_decoder.Image(
image_key=’image/encoded’,
format_key=’image/format’,
channels=3,
dct_method=dct_method),….
…..
….
..
.
}
slim_example_decoder.Image is tf.contrib.slim.tfexample_decoder.Image

In Tensorflow 1.5 source code tf.contrib.slim.tfexample_decoder.Image doesn’t have dct_method argument. Therefore when dct_method argument is passed it throws an error.

A simple hack would be to not pass this argument. So edit tf_example_decoder.py line 110 to remove dct_method=dct_method. I tried this and it worked and didn’t had any effect on training.

将 dct_method=dct_method 给去掉.

根据提供的引用内容,出现了TypeError: __init__() got an unexpected keyword argument 'date'和TypeError: __init__() got an unexpected keyword argument ‘encoding’的问题。这两个错误通常是由于使用了不支持的参数导致的。 对于第一个错误,TypeError: __init__() got an unexpected keyword argument 'date',这个错误通常发生在调用某个函数或方法时传递了不支持的参数。要解决这个问题,你需要检查你的代码,确保你传递的参数是正确的,并且与函数或方法的定义相匹配。 对于第二个错误,TypeError: __init__() got an unexpected keyword argument ‘encoding’,这个错误通常发生在使用json模块读取json文件时传递了不支持的参数。要解决这个问题,你需要检查你的代码,确保你传递的参数是正确的,并且与json模块的函数或方法的定义相匹配。 以下是两个示例来演示如何解决这两个错误: 1. 解决TypeError: __init__() got an unexpected keyword argument 'date'错误的示例: ```python class Person: def __init__(self, name): self.name = name person = Person(name='John', date='2021-01-01') # 错误的调用,传递了不支持的参数'date' ``` 在上面的示例中,我们在实例化Person类时传递了一个不支持的参数'date',导致了TypeError: __init__() got an unexpected keyword argument 'date'错误。要解决这个错误,我们需要检查代码并删除不支持的参数'date'。 2. 解决TypeError: __init__() got an unexpected keyword argument ‘encoding’错误的示例: ```python import json with open('data.json', 'r', encoding='utf-8') as file: # 错误的调用,传递了不支持的参数'encoding' data = json.load(file) ``` 在上面的示例中,我们在使用json模块读取json文件时传递了一个不支持的参数'encoding',导致了TypeError: __init__() got an unexpected keyword argument ‘encoding’错误。要解决这个错误,我们需要检查代码并删除不支持的参数'encoding'。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

mtj66

看心情

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值