namedtuple siz的python表达式

2024-09-27 19:26:58 发布

您现在位置:Python中文网/ 问答频道 /正文

我在python中遇到了以下表达式。我相信这个表达本身是合法的,它的构造方式实际上是有意义的。但是,从强类型的背景来看,我想知道人们是否通常在python中这样做。。。i、 e.使用同一个类来表达两个完全不同的概念(数据与数据大小元数据)

class AttentionDecoderOutput(
    namedtuple("DecoderOutput", [
        "logits", "predicted_ids", "cell_output", "attention_scores",
        "attention_context"
    ])):
  """Augmented decoder output that also includes the attention scores.
  """
  pass

AttentionDecoderOutput定义数据结构。下面的输出大小定义了namedtuple中每个元素的大小。在

^{pr2}$

Tags: 数据概念类型output定义表达式方式namedtuple

热门问题