Access, initialization and sharing of Python model parameters
Firstly, a multi-layer perceptron with a single hidden layer is defined, its parameters are initialized by the default method, and a forward operation is performed.
import torch
from torch import nn
from torch.nn import init
net=nn.Sequential(nn.Linear(4,3),nn.ReLU(),nn.Linear(3,1))
#Pytoch will be initialized by default
print(net)
X=torch.r ...
Posted by sgt.wolfgang on Mon, 27 Sep 2021 19:06:33 -0700
Triple loss using Pytorch
In this article, we will explore how to build a simple network model with triple loss. It is widely used in face verification, face recognition and signature verification. Before entering the code, let's learn what triple loss is and how to implement it in PyTorch.
Triple loss
Triple loss function is a widely used loss function at present. It ...
Posted by sam_rich on Sun, 26 Sep 2021 16:22:22 -0700
Fourth week assignment: convolutional neural network (Part2)
Modern neural network
This week, I mainly learned several classic modern neural networks: AlexNet, VGG, NiN, geoglenet and ResNet. These networks can be regarded as a process of continuous refinement in the development of neural networks: Starting from the LeNet network, AlexNet is generated by changing the activation function and using DropOu ...
Posted by joey3002 on Sat, 25 Sep 2021 00:04:14 -0700
[in depth learning] 60 questions PyTorch simple introduction guide to be a trendsetter of Technology
1. Get to know PyTorch
1.1 tensor
1. Import pytorch package
import torch
2. Create an empty 5x3 tensor
x = torch.empty(5, 3)
print(x)
3. Create a randomly initialized 5x3 tensor
x = torch.rand(5, 3)
print(x)
4. Create a 5x3 0 tensor of type long
x = torch.zeros(5, 3, dtype=torch.long)
print(x)
5. Create tensors directly from the a ...
Posted by jbbadaz on Wed, 22 Sep 2021 22:07:11 -0700
nn.Conv2d -- Interpretation of two-dimensional convolution operation
nn.Conv2d -- two dimensional convolution operation
torch.nn.Conv2d(in_channels, out_channels, kernel_size, stride=1, padding=0, dilation=1, groups=1, bias=True, padding_mode='zeros', device=None, dtype=None)
Function: 2D convolution operation is applied to the input signal composed of multiple input planes, which is commonly used in imag ...
Posted by dazraf on Sun, 19 Sep 2021 17:59:02 -0700
Datawhale September Group Learning--Emotional Analysis--Task01
Tip 1: Learning Address Point Here Tip 1: Word embeddings: how to transform text into numbers
Preface
_Task01 mainly uses RNN framework (note: this paper does not give a detailed explanation of RNN principles), IMDB dataset to build a Baseline model of text affective analysis tasks.
1. Model building process
1.1 Data Preprocessing
...
Posted by semtex on Wed, 15 Sep 2021 09:34:10 -0700
[pytorch] freeze part of the network
Preface
The best, most efficient and most concise is Plan One.
Scheme One
Step 1: Fixed basic network
Code template:
# Get the state_dict for the fixed part:
pre_state_dict = torch.load(model_path, map_location=torch.device('cpu')
# Imported (remember strict=False):
model.load_state_dict(pre_state_dict, strict=False)
print('Load mode ...
Posted by tauchai83 on Tue, 14 Sep 2021 09:46:30 -0700
Pytoch learning notes -- transforms
Why transforms?
Generally, the collected image samples are different in size and brightness. In deep learning, we want the sample distribution to be independent and identically distributed, so we need to normalize the samples.Sometimes only a small amount of sample data can be obtained, and it is not easy to obtain a large number of samples. H ...
Posted by The Chancer on Sun, 12 Sep 2021 00:49:40 -0700
Recognition of fashion MNIST data set by convolutional neural network (DenseNet) (pytoch version)
1. Preface
1.1 case introduction
In this case, pytoch is used to build a DenseNet network structure for image classification of fashion MNIST dataset. The analysis of this problem can be divided into data preparation, model establishment, training with training set and testing the effect of model with test set.
1.2 environment configurat ...
Posted by OhLordy on Fri, 10 Sep 2021 01:45:07 -0700
Image classification for deep learning -- a detailed explanation of Vision Transformer(ViT) network
Deep learning image classification (XVIII) detailed explanation of Vision Transformer(ViT) network
In the previous section, we talked about the self attention structure in Transformer. In this section, learn the detailed explanation of Vision Transformer(vit). Learning video from Bilibili , refer to blog Detailed explanation of Vision Tran ...
Posted by seaweed on Thu, 09 Sep 2021 21:09:01 -0700