0

I'm trying to understand what does this operator @, uses in python. I saw something about matrix multipication , but this is sure not the case,I'll give an example:

 @property
 def num_reserved_ids(self):
    return 0

Or:

 @registry.register_problem()
 class LibrispeechNoisy(Librispeech):

Last one:

@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 is another file that is used in the program.register_hparams is a function inside. Don't know what "property" is, but even registry that I know what it is, I can't understand the purpose of the operator :@, I'm a bit slow, sorry for that :/ ..

If anyone wants to look for some more code you can check tensor2tensor library: https://github.com/tensorflow/tensor2tensor/tree/master/tensor2tensor

Vadim Kotov
  • 7,103
  • 8
  • 44
  • 57
albert1905
  • 137
  • 1
  • 10
  • 2
    It's called a _decorator_ but your examples are a bit diverse for me to think how to answer this. – roganjosh Aug 08 '18 at 11:48
  • 2
    `numpy` uses `@` as the matrix multiplication sign. standard Python uses it for [decorators](https://www.thecodeship.com/patterns/guide-to-python-function-decorators/). – Ma0 Aug 08 '18 at 11:48
  • I didn't duplicate on purpose,if that's what you're saying, I searched and nothing returned, but thanks for another source of information. – albert1905 Aug 08 '18 at 11:59
  • 1
    @albert1905 nobody suggested that you did, and please don't take duplicates as some indication you did something wrong. You found a different way of wording some problem, so it will act as a signpost to the correct explanation :) Now a different combination of words in a Google search are more likely to get someone to the answer they want. – roganjosh Aug 08 '18 at 12:01

1 Answers1

2

I think what you are looking for is called PythonDecorators

Here is the 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.

The best way to understand them is from Corey Schafer's Video on Python Decorators

Shan-Desai
  • 2,331
  • 1
  • 33
  • 62