【发布时间】:2019-12-30 13:32:32
【问题描述】:
我正在研究对象检测问题,我想使用循环学习率。问题是,这种特定的学习在 TensorFlow 目标检测的原型中并不存在。我想知道是否可以修改 protos(或其他文件)以实现这种新的学习率方法?
我正在使用 Tensorflow 1.14 和最新更新版本的 Tensorflow 对象检测存储库。
我尝试修改 optimizer.proto 和 optimizer_pb2.py 文件。我只显示我修改的部分。
优化器.proto
// Configuration message for optimizer learning rate.
message LearningRate {
oneof learning_rate {
ConstantLearningRate constant_learning_rate = 1;
ExponentialDecayLearningRate exponential_decay_learning_rate = 2;
ManualStepLearningRate manual_step_learning_rate = 3;
CosineDecayLearningRate cosine_decay_learning_rate = 4;
CosineDecayRestartLearningRate cosine_decay_restart_learning_rate = 5; // Added
}
}
...
// Added for test
message CosineDecayRestartLearningRate {
optional uint32 total_steps = 1 [default = 400000];
}
optimizer_pb2.py
>_LEARNINGRATE = _descriptor.Descriptor(
...
full_name='object_detection.protos.LearningRate.cosine_decay_restart_learning_rate', index=4,
number=5, type=11, cpp_type=10, label=1,
has_default_value=False, default_value=None,
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
options=None),
...)
...
_COSINEDECAYRESTARTLEARNINGRATE = _descriptor.Descriptor(
name='CosineDecayRestartLearningRate',
full_name='object_detection.protos.CosineDecayRestartLearningRate',
filename=None,
file=DESCRIPTOR,
containing_type=None,
fields=[
_descriptor.FieldDescriptor(
name='total_steps', full_name='object_detection.protos.CosineDecayLearningRate.total_steps', index=1,
number=2, type=13, cpp_type=3, label=1,
has_default_value=True, default_value=4000000,
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
options=None),
],
extensions=[
],
nested_types=[],
enum_types=[
],
options=None,
is_extendable=False,
syntax='proto2',
extension_ranges=[],
oneofs=[
],
serialized_start=1671,
serialized_end=1861,
)
_LEARNINGRATE.fields_by_name['cosine_decay_restart_learning_rate'].message_type = _COSINEDECAYRESTARTLEARNINGRATE
_LEARNINGRATE.oneofs_by_name['learning_rate'].fields.append(
_LEARNINGRATE.fields_by_name['cosine_decay_restart_learning_rate'])
_LEARNINGRATE.fields_by_name['cosine_decay_restart_learning_rate'].containing_oneof = _LEARNINGRATE.oneofs_by_name['learning_rate']
DESCRIPTOR.message_types_by_name['CosineDecayRestartLearningRate'] = _COSINEDECAYRESTARTLEARNINGRATE
CosineDecayRestartLearningRate = _reflection.GeneratedProtocolMessageType('CosineDecayRestartLearningRate', (_message.Message,), dict(
DESCRIPTOR = _COSINEDECAYRESTARTLEARNINGRATE,
__module__ = 'object_detection.protos.optimizer_pb2'
# @@protoc_insertion_point(class_scope:object_detection.protos.CosineDecayRestartLearningRate)
))
_sym_db.RegisterMessage(CosineDecayRestartLearningRate)
我没想到它会起作用,因为我从来没有达到为学习率添加输入代码的步骤,它确实给了我一个错误。
File "/home/renart/Tensorflow/models/research/object_detection/protos/optimizer_pb2.py", line 253, in <module>
options=None),
File "/home/renart/Tensorflow/venv-1.13/lib/python3.5/site-packages/google/protobuf/descriptor.py", line 534, in __new__
return _message.default_pool.FindFieldByName(full_name)
KeyError: "Couldn't find field object_detection.protos.LearningRate.cosine_decay_restart_learning_rate"
不幸的是,错误来自 Protobuf 而不是 Tensorflow,所以我仍然不知道在哪里可以实现学习率。
【问题讨论】:
标签: python tensorflow object-detection