主頁 >  其他 > 深度學習框架PyTorch的技巧總結

深度學習框架PyTorch的技巧總結

2021-02-01 11:00:50 其他

1.在訓練模型時指定GPU的編號

  1. 設定當前使用的GPU設備僅為0號設備,設備名稱為"/gpu:0",os.environ["CUDA_VISIBLE_DEVICES"]="0";
  2. 設定當前使用的GPU設備為0,1兩個設備,名稱依次為"/gpu:0","/gpu:1",os.environ["CUDA_VISIBLE_DEVICES"]="0,1";根據順序優先表示使用0號設備,然后使用1號設備;
  3. 同樣,也可以在訓練腳本外面指定,CUDA_VISIBLE_DEVICES=0,1 python train.py,注意,如果此時使用的是8卡中的6和7,CUDA_VISIBLE_DEVICES=6,7 python train.py,但是在模型并行化的時候,仍然指定0和1,model=nn.DataParallel(mode, devices=[0,1];
    在這里,需要注意的是,指定GPU的命令需要放在和網路模型操作的最前面;

2.查看模型每層的輸如輸出詳情

  • 1.需要安裝torchsummary或者torchsummaryX(pip install torchsummary);
  • 2.使用示例如下:
from torchvision import models

vgg16 = models.vgg16()
vgg16 = vgg16.cuda()

# 1.torchsummary使用方法
from torchsummary import summary
summary(vgg16, (3, 224, 224))    # (3, 224, 224)是網路模型的輸入尺寸

# 2.torchsummaryX使用方法
from torchsummaryX import summary as summaryX

inputx = torch.randn(1, 3, 224, 224)
summaryX(vgg16, inputx)  

輸出的結果如下圖所示(每層輸出的shape以及模型的計算量):
輸出結果

3.梯度裁剪:防止在模型優化程序中出現梯度爆炸或者彌散

import torch
import torch.nn as nn

...
outputx = model(inputx)
optimizer.zero_grad()
loss.backward()
nn.utils.clip_grad_norm_(model.parameters(), max_norm=20, norm_type=2)
optimizer.step()

nn.utils.clip_grad_norm_的引數:

  1. parameters:基于變數的迭代器,會進行梯度歸一化;
  2. max_norm:梯度的最大范數;
  3. norm_type:規定范數的型別,默認為L2;
  4. 需要注意的是,梯度裁剪在某些任務上會額外消耗大量的計算時間,

4.擴張單張圖片的維度

因為在模型訓練的時候,輸入資料的維度是(batch_size,c,h,w),而在測驗的時候是單張圖片(c,h,w),所以會需要進行維度擴張

import cv2
import torch
import numpy as np
    
####### 基于numpy的方法 #########
# 方法1.
image = cv2.imread(imgpath)
print(image.shape)
image = image[np.newaxis, :, :, :]
print(image.shape)   

####### 基于pytorch的方法 #########
# 方法2.
image = cv2.imread(imgpath)
image = torch.tensor(image)
print(image.shape)
image = image.view(1, *image.shape)
print(image.shape)

# 方法3.
image = cv2.imread(imgpath)
image = torch.tensor(image)
print(image.shape)
image = image.unsqueeze(dim=0)
print(image.shape)

tensor.unsqueeze(dim):擴展維度,dim指定擴展哪個維度;tensor.squeeze(dim):去除dim指定的且size為1的維度,當維度都大于1時,seqeeze()不起作用,不指定dim時,去除所有size為1的維度,

5.one-hot編碼

在PyTorch里面的定義的交叉熵的時候,會自動把label轉換成one-hot編碼,所以不需要手動轉換,而使用MSE需要手動轉換成one-hot編碼,以下是轉換示例:

import torch
class_num = 8
batch_size = 4

def one_hot(label):
	"""
	Convert the label of one division to one-hot
	Argument:
		label: (type, tensor), the gt label, shape: (batch_size,)
	Return:
		one_hot_out: (type, tensor), the one-hot label, shape: (batch_size, class_num)
	"""
	label = label.resize_(batch_size, 1)
	m_zeros = torch.zeros(batch_size, class_num)
	one_hot_out = m_zeros.scatter_(1, label, 1)    # (dim, index, value)
	return one_hot_out

label = torch.LongTensor(batch_size).random_() % class_num
print(one_hot(label))

在PyTorch1.1之后,one_hot函式可以直接呼叫torch.nn.functional.one_hot

import torch
import torch.nn.functional as F

tensor = torch.arange(0, 5) % 3
one_hot = F.one_hot(tensor)

# F.one_hot會檢測不同類別的個數,生成對應的one-hot,也可以自己定義類別數
one_hot = F.one_hot(tensor, num_classes=10)

6.在驗證模型時,防止顯存爆炸

在驗證模型的程序中是不需要求導,既不需要梯度計算,關閉autograd,可以提高速度,節約記憶體,如果不關閉可能會爆顯存:

with torch.no_grad():
	model.eval()

7.學習率的衰減策略

在模型的訓練程序中動態地調整學習率,避免陷入區域優化點,

import torch
import torch.optim as optim
from torch.optim import lr_scheduler

# init optimier
optimizer = optim.Adam(model.parameters(), lr=0.001)
scheduler = lr_scheduler.StepLR(optimizer, 10, 0.1)     # 每隔10個epoch,學習率乘以0.1

# train process
for n in n_epoch:
	scheduler.step()
...

8.訓練程序中凍結某些層的引數

當加載預訓練模型的時候,或者在遷移學習中的分類模型,需要凍結前面幾層,保證其features不動,使其在訓練程序中不發生變化,

from torchvision import models

net = models.vgg16()
for name, value in net.named_parameters():
	print('name: {0}, \t grad: {1}'.format(name, value.requires_grad)
    
no_grad = ['cnn.VGG_16.convolution1_1.weight', 
            'cnn.VGG_16.convolution1_1.bias'
          ]
   
for name, value in net.named_parameters():
    if name in no_grad:
        value.requires_grad = False
    else:
        value.requires_grad = True
            
# 定義優化器
optimizer = optim.Adam(filter(lambda p: p.requires_grad, net.parameters()), lr=0.01)

9.訓練程序中針對不同的層設定不同的學習率

根據模型在優化程序中,會根據需要,對不同的層,設定不同的的學習率,代碼如下:

from torchvision import models

net = models.vgg16()
for name, value in net.named_parameters():
	print('name: {}'.format(name)
    
# split the layer according to the key words,
# feature layers:finetune,classifiery layers:from scratch
conv_params = []
fc_params = []
for name, params in net.named_parameters():
	if 'conv' in name:
    	conv_params += [params]
    else:
    	fc_params += [params]
        
# define the optimizer
optimizer = optim.Adam([
            	{'params': conv_params, 'lr': 1e-4}, 
                {'params': fc_params, 'lr': 1e-2}], weight_decay=1e-3)

將模型層劃分為兩部分,存放于一個串列中,每個部分就對應上面的一個字典,在字典里設定不同的學習率,當這兩部分有相同的其他引數時,就將該引數放到串列外面作為全域引數,就像上面的’weight_decay’,也可以在串列外面設定一個全域學習率,當各個部分字典里設定了區域學習率時,就使用該學習率,否則就使用串列外面的全域學習率optimizer = optim.Adam([{'params': conv_params, 'lr': 1e-4}], lr=1e-2, weight_decay=1e-3)

10.模型的保存和加載方式

在模型的訓練程序中需要對模型進行保存,使用模型的時候需要加載訓練好的模型,Pytorch中保存和加載模型的主要分為兩類:1. 保存加載整個模型;2. 只保存加載模型引數;

1.保存加載模型基本用法

  1. 保存加載整個模型(網路結構+模型的引數,比較耗時)
# save model
torch.save(model, 'net.pkl')

# load model 
model = torch.load('net.pkl')     # the model must have be defined
  1. 只保存加載模型引數(速度快,占記憶體少,推薦方法)
# save model parameters
torch.save(model.state_dict(), 'net_params.pkl'

# load model parameters, must build model firstly, load parameters secondly
model = Net()
state_dict = torch.load('net_params.pkl')
model.load_state_dict(state_dict)

2.保存加載自定義模型

上面保存的net.pkl檔案其實是一個字典,通常包括以下內容: a.網路結構:輸入尺寸,輸出尺寸以及隱含層資訊,以便能夠在加載時重建模型; b.模型的權重引數:包括各個網路層訓練后的可學習引數,可以在模型實體上呼叫state_dict()方法來獲取,比如只保存模型權重引數時用到的model.state_dict(); c.優化器引數:有時候保存模型之后需要接著訓練,那么就必須保存優化器的狀態和所使用的超引數,也就是在優化器實體上呼叫state_dict()方法來獲取這些引數; d.其他資訊:有時候需要保存其他資訊,比如epoch,batch_size等超引數, 這樣就可以自定義需要保存的內容,如下所示,

# saving a checkpoint assuming the network class named Net
checkpoint = {
    'model':Net(), 
    'model_state_dict':model.state_dict(), 
    'optimizer_state_dict':optimizer.state_dict(),
    'epoch':epoch
}

torch.save(chekpoint, 'checkpoint.pkl')

# load the model infor
def load_checkpoint(filepath):
    checkpoint = torch.load(filepath)
    model = checkpoint['model']     # 網路結構
    model.load_state_dict(checkpoint['model_state_dict'])    # 加載網路模型引數
    optimizer = optim.SGD()
    optimizer.load_state_dict(checkpoint['optimizer_state_dict'])    # 加載優化器引數

    for params in model.parameters():
        params.requires_grad = False
    
    model.eval()
    return model 

model = load_checkpoint('checkpoint.pkl')

加載模型是為了進行測驗,則將每一層的requires_grad置為False,固定這些引數;還需要呼叫model.eval()將模型置為測驗模式,主要是將DropoutBatchNormalization進行固定,否則模型的預測結果每次都會不同,如果繼續訓練,則呼叫model.train()確保網路模型處于訓練模式,

3.跨設備保存加載模型

  1. 在GPU上訓練的模型,在CPU上加載(Save on GPU, Load on CPU):

    device = torch.device('cpu')
    model = Net()
    # load all tensors onto the CPU device
    model.load_state_dict(torch.load('net_params.pkl', map_location=device))
    # <===> model.load_state_dict(torch.load('net_params.pkl', map_location='cpu'))
    
  2. 在GPU上訓練的模型,在GPU上加載(Save on GPU, Load on GPU):

    device = torch.device('cuda')
    model = Net()
    model.load_state_dict(torch.load('net_params.pkl'))
    model.to(device)
    

在這里使用map_location引數不起作用,要使用model.to(torch.device("cuda"))將模型轉換為CUDA優化的模型,

還需要對將輸入模型的資料呼叫data=data.to(device),即將資料從CPU轉到GPU,注意,呼叫my_tensor.to(device)會回傳一個my_tensor在GPU上的副本,它不會覆寫my_tensor,因此需要手動覆寫張量:my_tensor = my_tensor.to(device)

  1. 在CPU上訓練的模型,在GPU上加載(Save on CPU, Load on GPU):

    device = torch.device('cuda')
    model = Net()
    model.load_state_dict(torch.load('net_params.pkl', map_location='cuda:0'))
    model.to(device)
    

11.GPU相關的幾個函式

# 判斷cuda時候可用
print(torch.cuda.is_available()

# 獲取gpu數量
print(torch.cuda.device_count()

# 獲取gpu名字
print(torch.cuda.get_device_name(0))

# 獲取當前gpu設備索引,默認從0開始
print(torch.cuda.current_device())

# 將模型和資料從cpu移到gpu
use_cuda = torch.cuda.is_available()

# 方法1
if use_cuda:
    data = data.cuda()
    model.cuda()

# 方法2
device = torch.device('cuda' if use_cuda else 'cpu')
data = data.to(device)
model.to(device)

12.列印模型在inference中的特征圖

  1. 包裝模型(在forward中輸出特征圖);
import os
import cv2
import numpy as np
from PIL import Image

import torch
import torch.nn as nn
import torch.nn.functional as F
import torchvision.models as models


class FeatureVisualizaiton:
    input_size = 256
    def __init__(self, imgpath='', layers_idx=[1, 2], save_features_dir='/'):
        self.imgpath = imgpath
        self.layers_idx = layers_idx
        self.save_features_dir= save_features_dir
        self.net = models.vgg16()
    
    @staticmethod
    def preprocess_image(imgpath):
        assert os.path.isfile(imgpath), "The image of {%s} must be existed!" % imgpath
        img = cv2.imread(imgpath)
        # resize
        img = cv2.resize(img, (input_size, input_size))
        # normalize as [0, 1]
        img = (img / 255.).astype('float32').transpose((2, 0, 1))[np.newaxis, :, :, :]   # (1, 3, 256, 256)
        # <===>
        # img = (img / 255.).astype('float32').swapaxis(1, 2).swapaxis(0, 1)
        # img = np.expand_dims(img, axis=0)
        img = torch.from_numpy(img)
        return img
       
    def get_features(self):
        """Extract features"""
        features = {}
        inputx = self.preprocess_image(self.imgpath)
        print('inputx shape', inputx.shape)
        if torch.cuda.is_available():
            inputx = inputx.cuda()
            model = self.net.cuda()
            
        x = inputx 
        for index, (name, module) in enumerate(model.named_modules()):
            x = module(x)
            if index in self.layers_idx:
                features[name] = x
        return features
        
    def save_features(self):
        """Save features"""
        features = self.get_features()
        for name, feature in features.items():
            feature = self.process_feature(feature)
            cv2.imwrite(os.path.join(self.save_features_dir, name + '.jpg'), feature)
        
        
    @statcimethod
    def process_feature(feature):
        """
        Normalize the feature
        Arguments:
            feature: (type, tensor(b, c, h, w)), normalize to (0, 255) 
        """
        feature = feature.cpu().detach().numpy()
        
        # use sigmoid to [0, 1]
        feature = (1.0 / (1 + np.exp(-1 * feature))
        feature = np.round(feature * 255)
        return feature

if __name__ == '__main__':
    featurevisualization = FeatureVisualization()
    featurevisualization.save_features()
  1. 使用hook:利用pytorch里面的hook,可以不改變輸入輸出中間的網路結構,可以方便的獲取,改變網路中間層的值和梯度(幾種hook和forward,backward的先后關系在nn.module__call__函式里面可以看得更清楚),可以看到,對于register_forward_hook在forward的呼叫之后,
import os
import cv2
import numpy as np
from PIL import Image

import torch
import torch.nn as nn
import torch.nn.functional as F
import torchvision.models as models


class FeatureVisualizaiton:
    input_size = 256
    def __init__(self, imgpath='', layers_idx=[1, 2], save_features_dir='/'):
        self.imgpath = imgpath
        self.layers_idx = layers_idx
        self.save_features_dir= save_features_dir
        self.net = models.vgg16()
    
    @staticmethod
    def preprocess_image(imgpath):
        assert os.path.isfile(imgpath), "The image of {%s} must be existed!" % imgpath
        img = cv2.imread(imgpath)
        # resize
        img = cv2.resize(img, (input_size, input_size))
        # normalize as [0, 1]
        img = (img / 255.).astype('float32').transpose((2, 0, 1))[np.newaxis, :, :, :]   # (1, 3, 256, 256)
        # <===>
        # img = (img / 255.).astype('float32').swapaxis(1, 2).swapaxis(0, 1)
        # img = np.expand_dims(img, axis=0)
        img = torch.from_numpy(img)
        return img
       
    def get_features(self):
        """Extract features"""
        features = {}
        inputx = self.preprocess_image(self.imgpath)
        print('inputx shape', inputx.shape)
        if torch.cuda.is_available():
            inputx = inputx.cuda()
            model = self.net.cuda()
        
        # closure
        def get_activation(name):
            def hook(model, input, output):
                features[name] = output.detach()
            return hook
        
        # register hook
        for layer_idx in self.layers_idx:
            handle = model[layer_idx].register_forward_hook(get_activation(str(layer_idx))

        outputx = model(inputx)
        handle.remove()
        
        return features
        
    def save_features(self):
        """Save features"""
        features = self.get_features()
        for name, feature in features.items():
            feature = self.process_feature(feature)
            cv2.imwrite(os.path.join(self.save_features_dir, name + '.jpg'), feature)
        
    @statcimethod
    def process_feature(feature):
        """
        Normalize the feature
        Arguments:
            feature: (type, tensor(b, c, h, w)), normalize to (0, 255) 
        """
        feature = feature.cpu().detach().numpy()
        
        # use sigmoid to [0, 1]
        feature = (1.0 / (1 + np.exp(-1 * feature))
        feature = np.round(feature * 255)
        return feature

if __name__ == '__main__':
    featurevisualization = FeatureVisualization()
    featurevisualization.save_features()

13.Tensor型別之間的轉換(三種方式)

  1. 使用獨立函式:

    import torch
    import torch.nn as nn
        
    x = torch.randn(3, 5)
    print(x)
    # convert x as long
    x_long = x.long()
    # convert x as half
    x_half = x.half()
    # convert x as int 
    x_int = x.int()
    # convert x as double
    x_double = x.double()
    # convert x as float
    x_float = x.float()
    # convert x as char
    x_char = x.char()
    # convert x as byte
    x_byte = x.byte()
    # convert x as short
    x_short = x.short()
    
  2. 使用**torch.type()**函式:

    import torch
    import torch.nn as nn
        
    x = torch.randn(3, 5)
    x_int = x.type(torch.IntTensor)
    print(x_int)
    
  3. 使用**type_as(ano_tensor)**將tensor轉換為給定型別的tensor:

    import torch
    import torch.nn as nn
        
    x = torch.FloatTensor(5)    
    y = torch.IntTensor([10, 20])
        
    x_int = x.type_as(y)
    assert isinstance(x_int, torch.IntTensor)
    

該文章總結了自己在pytorch使用程序中的一些小技識訓累,后續會持續更新,如果有錯誤不當之處,歡迎各位大牛批評指正!

轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/255142.html

標籤:AI

上一篇:用Python標記識別人臉制作鏤空圖案的“笑臉”照片墻

下一篇:C++初識

標籤雲
其他(157675) Python(38076) JavaScript(25376) Java(17977) C(15215) 區塊鏈(8255) C#(7972) AI(7469) 爪哇(7425) MySQL(7132) html(6777) 基礎類(6313) sql(6102) 熊猫(6058) PHP(5869) 数组(5741) R(5409) Linux(5327) 反应(5209) 腳本語言(PerlPython)(5129) 非技術區(4971) Android(4554) 数据框(4311) css(4259) 节点.js(4032) C語言(3288) json(3245) 列表(3129) 扑(3119) C++語言(3117) 安卓(2998) 打字稿(2995) VBA(2789) Java相關(2746) 疑難問題(2699) 细绳(2522) 單片機工控(2479) iOS(2429) ASP.NET(2402) MongoDB(2323) 麻木的(2285) 正则表达式(2254) 字典(2211) 循环(2198) 迅速(2185) 擅长(2169) 镖(2155) 功能(1967) .NET技术(1958) Web開發(1951) python-3.x(1918) HtmlCss(1915) 弹簧靴(1913) C++(1909) xml(1889) PostgreSQL(1872) .NETCore(1853) 谷歌表格(1846) Unity3D(1843) for循环(1842)

熱門瀏覽
  • 網閘典型架構簡述

    網閘架構一般分為兩種:三主機的三系統架構網閘和雙主機的2+1架構網閘。 三主機架構分別為內端機、外端機和仲裁機。三機無論從軟體和硬體上均各自獨立。首先從硬體上來看,三機都用各自獨立的主板、記憶體及存盤設備。從軟體上來看,三機有各自獨立的作業系統。這樣能達到完全的三機獨立。對于“2+1”系統,“2”分為 ......

    uj5u.com 2020-09-10 02:00:44 more
  • 如何從xshell上傳檔案到centos linux虛擬機里

    如何從xshell上傳檔案到centos linux虛擬機里及:虛擬機CentOs下執行 yum -y install lrzsz命令,出現錯誤:鏡像無法找到軟體包 前言 一、安裝lrzsz步驟 二、上傳檔案 三、遇到的問題及解決方案 總結 前言 提示:其實很簡單,往虛擬機上安裝一個上傳檔案的工具 ......

    uj5u.com 2020-09-10 02:00:47 more
  • 一、SQLMAP入門

    一、SQLMAP入門 1、判斷是否存在注入 sqlmap.py -u 網址/id=1 id=1不可缺少。當注入點后面的引數大于兩個時。需要加雙引號, sqlmap.py -u "網址/id=1&uid=1" 2、判斷文本中的請求是否存在注入 從文本中加載http請求,SQLMAP可以從一個文本檔案中 ......

    uj5u.com 2020-09-10 02:00:50 more
  • Metasploit 簡單使用教程

    metasploit 簡單使用教程 浩先生, 2020-08-28 16:18:25 分類專欄: kail 網路安全 linux 文章標簽: linux資訊安全 編輯 著作權 metasploit 使用教程 前言 一、Metasploit是什么? 二、準備作業 三、具體步驟 前言 Msfconsole ......

    uj5u.com 2020-09-10 02:00:53 more
  • 游戲逆向之驅動層與用戶層通訊

    驅動層代碼: #pragma once #include <ntifs.h> #define add_code CTL_CODE(FILE_DEVICE_UNKNOWN,0x800,METHOD_BUFFERED,FILE_ANY_ACCESS) /* 更多游戲逆向視頻www.yxfzedu.com ......

    uj5u.com 2020-09-10 02:00:56 more
  • 北斗電力時鐘(北斗授時服務器)讓網路資料更精準

    北斗電力時鐘(北斗授時服務器)讓網路資料更精準 北斗電力時鐘(北斗授時服務器)讓網路資料更精準 京準電子科技官微——ahjzsz 近幾年,資訊技術的得了快速發展,互聯網在逐漸普及,其在人們生活和生產中都得到了廣泛應用,并且取得了不錯的應用效果。計算機網路資訊在電力系統中的應用,一方面使電力系統的運行 ......

    uj5u.com 2020-09-10 02:01:03 more
  • 【CTF】CTFHub 技能樹 彩蛋 writeup

    ?碎碎念 CTFHub:https://www.ctfhub.com/ 筆者入門CTF時時剛開始刷的是bugku的舊平臺,后來才有了CTFHub。 感覺不論是網頁UI設計,還是題目質量,賽事跟蹤,工具軟體都做得很不錯。 而且因為獨到的金幣制度的確讓人有一種想去刷題賺金幣的感覺。 個人還是非常喜歡這個 ......

    uj5u.com 2020-09-10 02:04:05 more
  • 02windows基礎操作

    我學到了一下幾點 Windows系統目錄結構與滲透的作用 常見Windows的服務詳解 Windows埠詳解 常用的Windows注冊表詳解 hacker DOS命令詳解(net user / type /md /rd/ dir /cd /net use copy、批處理 等) 利用dos命令制作 ......

    uj5u.com 2020-09-10 02:04:18 more
  • 03.Linux基礎操作

    我學到了以下幾點 01Linux系統介紹02系統安裝,密碼啊破解03Linux常用命令04LAMP 01LINUX windows: win03 8 12 16 19 配置不繁瑣 Linux:redhat,centos(紅帽社區版),Ubuntu server,suse unix:金融機構,證券,銀 ......

    uj5u.com 2020-09-10 02:04:30 more
  • 05HTML

    01HTML介紹 02頭部標簽講解03基礎標簽講解04表單標簽講解 HTML前段語言 js1.了解代碼2.根據代碼 懂得挖掘漏洞 (POST注入/XSS漏洞上傳)3.黑帽seo 白帽seo 客戶網站被黑帽植入劫持代碼如何處理4.熟悉html表單 <html><head><title>TDK標題,描述 ......

    uj5u.com 2020-09-10 02:04:36 more
最新发布
  • 2023年最新微信小程式抓包教程

    01 開門見山 隔一個月發一篇文章,不過分。 首先回顧一下《微信系結手機號資料庫被脫庫事件》,我也是第一時間得知了這個訊息,然后跟蹤了整件事情的經過。下面是這起事件的相關截圖以及近日流出的一萬條資料樣本: 個人認為這件事也沒什么,還不如關注一下之前45億快遞資料查詢渠道疑似在近日復活的訊息。 訊息是 ......

    uj5u.com 2023-04-20 08:48:24 more
  • web3 產品介紹:metamask 錢包 使用最多的瀏覽器插件錢包

    Metamask錢包是一種基于區塊鏈技術的數字貨幣錢包,它允許用戶在安全、便捷的環境下管理自己的加密資產。Metamask錢包是以太坊生態系統中最流行的錢包之一,它具有易于使用、安全性高和功能強大等優點。 本文將詳細介紹Metamask錢包的功能和使用方法。 一、 Metamask錢包的功能 數字資 ......

    uj5u.com 2023-04-20 08:47:46 more
  • vulnhub_Earth

    前言 靶機地址->>>vulnhub_Earth 攻擊機ip:192.168.20.121 靶機ip:192.168.20.122 參考文章 https://www.cnblogs.com/Jing-X/archive/2022/04/03/16097695.html https://www.cnb ......

    uj5u.com 2023-04-20 07:46:20 more
  • 從4k到42k,軟體測驗工程師的漲薪史,給我看哭了

    清明節一過,盲猜大家已經無心上班,在數著日子準備過五一,但一想到銀行卡里的余額……瞬間心情就不美麗了。最近,2023年高校畢業生就業調查顯示,本科畢業月平均起薪為5825元。調查一出,便有很多同學表示自己又被平均了。看著這一資料,不免讓人想到前不久中國青年報的一項調查:近六成大學生認為畢業10年內會 ......

    uj5u.com 2023-04-20 07:44:00 more
  • 最新版本 Stable Diffusion 開源 AI 繪畫工具之中文自動提詞篇

    🎈 標簽生成器 由于輸入正向提示詞 prompt 和反向提示詞 negative prompt 都是使用英文,所以對學習母語的我們非常不友好 使用網址:https://tinygeeker.github.io/p/ai-prompt-generator 這個網址是為了讓大家在使用 AI 繪畫的時候 ......

    uj5u.com 2023-04-20 07:43:36 more
  • 漫談前端自動化測驗演進之路及測驗工具分析

    隨著前端技術的不斷發展和應用程式的日益復雜,前端自動化測驗也在不斷演進。隨著 Web 應用程式變得越來越復雜,自動化測驗的需求也越來越高。如今,自動化測驗已經成為 Web 應用程式開發程序中不可或缺的一部分,它們可以幫助開發人員更快地發現和修復錯誤,提高應用程式的性能和可靠性。 ......

    uj5u.com 2023-04-20 07:43:16 more
  • CANN開發實踐:4個DVPP記憶體問題的典型案例解讀

    摘要:由于DVPP媒體資料處理功能對存放輸入、輸出資料的記憶體有更高的要求(例如,記憶體首地址128位元組對齊),因此需呼叫專用的記憶體申請介面,那么本期就分享幾個關于DVPP記憶體問題的典型案例,并給出原因分析及解決方法。 本文分享自華為云社區《FAQ_DVPP記憶體問題案例》,作者:昇騰CANN。 DVPP ......

    uj5u.com 2023-04-20 07:43:03 more
  • msf學習

    msf學習 以kali自帶的msf為例 一、msf核心模塊與功能 msf模塊都放在/usr/share/metasploit-framework/modules目錄下 1、auxiliary 輔助模塊,輔助滲透(埠掃描、登錄密碼爆破、漏洞驗證等) 2、encoders 編碼器模塊,主要包含各種編碼 ......

    uj5u.com 2023-04-20 07:42:59 more
  • Halcon軟體安裝與界面簡介

    1. 下載Halcon17版本到到本地 2. 雙擊安裝包后 3. 步驟如下 1.2 Halcon軟體安裝 界面分為四大塊 1. Halcon的五個助手 1) 影像采集助手:與相機連接,設定相機引數,采集影像 2) 標定助手:九點標定或是其它的標定,生成標定檔案及內參外參,可以將像素單位轉換為長度單位 ......

    uj5u.com 2023-04-20 07:42:17 more
  • 在MacOS下使用Unity3D開發游戲

    第一次發博客,先發一下我的游戲開發環境吧。 去年2月份買了一臺MacBookPro2021 M1pro(以下簡稱mbp),這一年來一直在用mbp開發游戲。我大致分享一下我的開發工具以及使用體驗。 1、Unity 官網鏈接: https://unity.cn/releases 我一般使用的Apple ......

    uj5u.com 2023-04-20 07:40:19 more