@python中行的开头的运算符

2024-06-25 06:32:25 发布

您现在位置: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)

注册表是在中使用的另一个文件程序寄存器\u hparams是一个函数。 不知道“属性”是什么,但即使我知道它是什么,我也不能理解操作符的目的:@,我有点慢,抱歉:/。。你知道吗

如果有人想寻找更多的代码,可以查看Tensor2传感器库: https://github.com/tensorflow/tensor2tensor/tree/master/tensor2tensor


Tags: registerforondef矩阵例子事实registry
1条回答
网友
1楼 · 发布于 2024-06-25 06:32:25

我想你要找的是Python

这是Wiki For Python Decorators

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

相关问题 更多 >