Understanding the mask mechanism in Transformer

Tips This article is suitable for students who have carefully read the Transformer paper and source code. The code used is the Pytorch version, and it only records my personal understanding during the learning process. If there are any mistakes, please communicate in the comment area. Thank you for your corrections. Prefixed content def forward(self, […]

[State Estimation] Combine Transformer and LSTM with the EM algorithm into the Kalman filter for state estimation (Python code implementation)…

?About the author: A Matlab simulation developer who loves scientific research. He cultivates his mind and improves his technology simultaneously. For cooperation on MATLAB projects, please send a private message. Personal homepage: Matlab Research Studio Personal credo: Investigate things to gain knowledge. For more complete Matlab code and simulation customization content, click Intelligent optimization algorithm […]

Unleashing the creativity of Transformers in generative AI

Introduction In the ever-growing field of artificial intelligence, one name has stood out in recent years: Transformer. These powerful models change the way we approach generative tasks in artificial intelligence, pushing the boundaries of what machines can create and imagine. In this article, we’ll take a deep dive into advanced applications of Transformers in generative […]

Another use method after InvokerTransformer is banned

CommonsCollections3 In CC1 and CC6, we finally called the calculator through Runtime.exec. From CC3, we will introduce a method to play the calculator without using Runtime, which is the dynamic class loading and dynamic class often mentioned in Java. Loading allows us to load a malicious class through a path. If the malicious class has […]

Week 16: Transformer architecture encoder code implementation (pytorch)

Week 16: Transformer architecture code implementation (pytorch) Summary Abstrct 1. Code implementation of the core part of Transformer encoder 1.1 Import dependent library files 1.2 Set word list size and maximum sequence length 1.3 Word index forms source sentence and target sentence 1.4 Construct word embedding word list 1.5 Construct position embedding 1.6 Construct the […]

OpenMMlab exports swin-transformer model and uses onnxruntime and tensorrt for inference

Export onnx file It is very easy to export the onnx file of swin-transformer through mmpretrain. Note that you need to set opset_version=12. This is a pitfall. The opset_version=11 set at the beginning will cause problems when converting trtengine later. import torch from mmpretrain import get_model, inference_model model = get_model(‘swin-tiny_16xb64_in1k’, pretrained=’swin_tiny_224_b16x64_300e_imagenet_20210616_090925-66df6be6.pth’, device=’cpu’) input = torch.zeros(1, […]

Natural language processing—Transformer builds language model

Language model overview Taking a sequence that conforms to the rules of language as input, the model will use features such as relationships between sequences to output a probability distribution over all words. Such a model is called a language model. # The training corpus of the language model generally comes from articles, and the […]

Swin Transformer code interpretation (1)

#swin_mlp.py # This is a standard two-layer full connection. The input feature (in_features dimension) passes through an fc to the intermediate feature (hidden_feature), passes through the activation function, and then passes through an fc to # Output (out_feature dimension) class Mlp(nn.Module): def __init__(self, in_features, hidden_features=None, out_features=None, act_layer=nn.GELU, drop=0.): super().__init__() out_features = out_features or in_features hidden_features […]

Classic network model series – Detailed explanation and code implementation of Swin-Transformer

1. Overall architecture of network model 2. Detailed explanation of Patch Partition module 3. Patch Merging module 4. Detailed explanation of W-MSA 5. Detailed explanation of SW-MSA Detailed explanation of masked MSA 6. Detailed explanation of Relative Position Bias 7. Model detailed configuration parameters 8. Important module code implementation: 1. Patch Partition code module: 2. […]