Exemple #1
0
 def __init__(self, dim, depth, heads, dim_head, patch_height, patch_width, scale = 4, depth_kernel = 3, dropout = 0.):
     super().__init__()
     self.layers = nn.ModuleList([])
     for _ in range(depth):
         self.layers.append(nn.ModuleList([
             Residual(PreNorm(dim, Attention(dim, heads = heads, dim_head = dim_head, dropout = dropout))),
             Residual(PreNorm(dim, ConvFF(dim, scale, depth_kernel, patch_height, patch_width)))
         ]))
 def __init__(self, dim, depth, heads, dim_head, mlp_dim, dropout=0.):
     super().__init__()
     self.layers = nn.ModuleList([])
     for _ in range(depth):
         self.layers.append(
             nn.ModuleList([
                 PreNorm(
                     dim,
                     Attention(dim,
                               heads=heads,
                               dim_head=dim_head,
                               dropout=dropout)),
                 PreNorm(dim, FeedForward(dim, mlp_dim, dropout=dropout))
             ]))