@ 运算符位于 python 中行的开头
@ operator at the beginning of the line in python
我想了解此运算符 @, 在 python 中的用途。
我看到一些关于矩阵乘法的东西,但肯定不是这样,我举个例子:
@property
def num_reserved_ids(self):
return 0
或:
@registry.register_problem()
class LibrispeechNoisy(Librispeech):
最后一个:
@registry.register_hparams
def transformer_librispeech_tpu_v1():
"""HParams for training ASR model on Librispeech on TPU v1."""
hparams = transformer_librispeech_v1()
update_hparams_for_tpu(hparams)
Registry是另一个文件,就是用在program.register_hparams里面的函数。
不知道 "property" 是什么,但即使我知道它是什么的注册表,我也无法理解操作员的目的:@,我有点慢,对此感到抱歉:/ ..
如果有人想查找更多代码,可以查看 tensor2tensor 库:
https://github.com/tensorflow/tensor2tensor/tree/master/tensor2tensor
我想你要找的是 PythonDecorators
A Python decorator is a specific change to the Python syntax that allows us to more conveniently alter functions and methods (and possibly classes in a future version). This supports more readable applications of the DecoratorPattern but also other uses as well.
了解它们的最佳方式来自Corey Schafer's Video on Python Decorators
我想了解此运算符 @, 在 python 中的用途。 我看到一些关于矩阵乘法的东西,但肯定不是这样,我举个例子:
@property
def num_reserved_ids(self):
return 0
或:
@registry.register_problem()
class LibrispeechNoisy(Librispeech):
最后一个:
@registry.register_hparams
def transformer_librispeech_tpu_v1():
"""HParams for training ASR model on Librispeech on TPU v1."""
hparams = transformer_librispeech_v1()
update_hparams_for_tpu(hparams)
Registry是另一个文件,就是用在program.register_hparams里面的函数。 不知道 "property" 是什么,但即使我知道它是什么的注册表,我也无法理解操作员的目的:@,我有点慢,对此感到抱歉:/ ..
如果有人想查找更多代码,可以查看 tensor2tensor 库: https://github.com/tensorflow/tensor2tensor/tree/master/tensor2tensor
我想你要找的是 PythonDecorators
A Python decorator is a specific change to the Python syntax that allows us to more conveniently alter functions and methods (and possibly classes in a future version). This supports more readable applications of the DecoratorPattern but also other uses as well.
了解它们的最佳方式来自Corey Schafer's Video on Python Decorators