From 43cf6e431b28b60b62d5689e42a591937d122154 Mon Sep 17 00:00:00 2001 From: Gustaf Rydholm Date: Wed, 27 Oct 2021 22:14:49 +0200 Subject: Remove unused import and add comments in attn module --- text_recognizer/networks/transformer/attention.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'text_recognizer/networks/transformer/attention.py') diff --git a/text_recognizer/networks/transformer/attention.py b/text_recognizer/networks/transformer/attention.py index 3d2ece1..9b33944 100644 --- a/text_recognizer/networks/transformer/attention.py +++ b/text_recognizer/networks/transformer/attention.py @@ -3,7 +3,6 @@ from typing import Optional, Tuple import attr from einops import rearrange -from einops.layers.torch import Rearrange import torch from torch import einsum from torch import nn @@ -18,6 +17,7 @@ class Attention(nn.Module): """Standard attention.""" def __attrs_pre_init__(self) -> None: + """Pre init constructor.""" super().__init__() dim: int = attr.ib() @@ -52,6 +52,7 @@ class Attention(nn.Module): context_mask: Optional[Tensor] = None, rotary_pos_emb: Optional[Tensor] = None, ) -> Tuple[Tensor, Tensor]: + """Computes the attention.""" b, n, _, device = *x.shape, x.device q = self.query(x) -- cgit v1.2.3-70-g09d2