Fine-tuning BART for Chinese and English translation tasks (Pytorch code)

Fine-tuning BART for Chinese and English translation tasks (Pytorch code) The full name of BART isBidirectional andAuto-RegressiveTransformers. As the name suggests, it is both contextual and contextual. Transformer with environmental information and autoregressive characteristics was proposed by FaceBook in 2019. Its structure is shown in the figure below. BART inherits all the encoder-decoder architecture of […]

[PyTorch Convolution] Practical customized image classification

Foreword Convolutional neural network is a type of feedforward neural network that contains convolutional calculations and has a deep structure. It is one of the representative algorithms of deep learning. It can effectively process through convolutional layers, pooling layers, fully connected layers and other structures. Such as time series and picture data, etc. There are […]

WSL2 Ubuntu22.04 + 3070 installation cuda11.6 +Pytorch1.13.0 full record

Article directory Install cuda Check the maximum supported cuda version Install according to the official website steps Aftermath after installation is complete Install cudnn Install PyTorch Install miniconda to manage the python environment Install Pytorch in torch_env Result check gpustat Install cuda Note in advance: If the WSL distribution version is Ubuntu22.04, an error occurred […]

About pytorch tensor dimension conversion and tensor operations

About pytorch tensor dimension conversion list 1 tensor.view() 2 tensor.reshape() 3 tensor.squeeze() and tensor.unsqueeze() 3.1 tensor.squeeze() dimensionality reduction 3.2 tensor.unsqueeze(idx) dimensionality increase 4 tensor.permute() 5 torch.cat([a,b],dim) 6 torch.stack() 7 torch.chunk() and torch.split() 8 Multiplication operation with tensor 9 Addition operation with tensor 10 tensor.expand() 11 tensor.narrow(dim, start, len) 12 tensor.resize_() 13 tensor.repeat() 14 unbind() refer […]

Deploy YoloV3-PyTorch using Flask

Use Flask to deploy YoloV3-PyTorch 1. Project Introduction This project is a small demo of web object detection, using Yolov3 (PyTorch) and Flask to perform object detection on the Web, involving target detection, Flask and Html Yolov3 comes from Ultralytics, you can use their project to train a model that suits you 2. Overall project […]

Solve the problem of converting pytorch model to onnx model, and the grid_sample function input parameter is 5-dimensional and the export fails

When transferring pytorch to onnx, grid_sample does not have a corresponding operator, so the transfer cannot be successful. The solutions on the Internet are all four-dimensional (4D) data input, but my input is five-dimensional (5D). I looked for the code and made modifications based on some codes. . The code does not consider performance, only […]

Pytorch01-tensor

1.torch.Tensor: 1. Data type: Multidimensional matrix containing elements of a single data type 2. Conversion of tensor type: Convert python list or sequence data into Tensor, dtype is torch.FloatTensor torch.tensor() 3. Change torch.dtype and torch.device: Use to() method torch.ones([2, 3], dtype=torch.float64, device=’cuda:0′) # if use mps need to change to mps of device # tensor([[1., […]

pytorch multi-process in python

Table of Contents 1. Create and run parallel processes 2. Use Queue to share data 3. Process pool 4. Process lock 5. Compare the time consumption of executing a piece of code using multiple processes and using a single process 6. Shared variables Multiprocessing is a term in computer science that refers to running multiple […]

Download and install Fairseq and pytorch under Windows (the simplest and most crude on the entire network)

I recently encountered a situation where fairseq installation failed when I was studying artificial intelligence. There are few introductions to fairseq installation on Windows on the Internet. After spending more than ten gigabytes of traffic over and over again, I finally found a solution. Installed using the conda environment. If you know the basic operations […]

pytorch recurrence 2_AlexNet

Does not involve principles AlexNet network structure Code: model: import torch.nn as nn import torch class AlexNet(nn.Module): def __init__(self, num_classes=1000, init_weights=False): super(AlexNet, self).__init__() self.features = nn.Sequential( nn.Conv2d(3, 48, kernel_size=11, stride=4, padding=2), # input[3, 224, 224] output[48, 55, 55] nn.ReLU(inplace=True), nn.MaxPool2d(kernel_size=3, stride=2), # output[48, 27, 27] nn.Conv2d(48, 128, kernel_size=5, padding=2), # output[128, 27, 27] nn.ReLU(inplace=True), nn.MaxPool2d(kernel_size=3, […]