四、Transforms

transform是torchvision下的一個.py文件,這個python文件中定義了很多的類和方法,主要實現對圖片進行一些變換操作

一、Transforms講解

from torchvision import transforms#按著Ctrl,點擊transforms

進入到__init__.py文件中

from .transforms import *#再次按著Ctrl,點擊.transforms
from .autoaugment import *

進入transform.py文件中,可以看到transforms其實就是transform.py一個python文件,可以理解為其是一個工具包
在這里插入圖片描述
點擊Structure,或Alt+7,查看下這個文件的大概結構框架
在這里插入圖片描述
File–Settings–keymap–structure,可以查看快捷鍵
在這里插入圖片描述
通俗點:transform指的就是transform.py文件,該文件里面有好多類,可以對圖像進行各種各樣的操作

二、ToTensor類

看下文檔給的使用說明
Ctrl+P:顯示方法所需要的參數
在這里插入圖片描述

    """Convert a ``PIL Image`` or ``numpy.ndarray`` to tensor. This transform does not support torchscript.
#可以看到其實就將PIL Image、numpy.ndarray類型的圖片轉換為tensor類型
#PIL針對的是Python自帶的Image進行open操作;numpy.ndarray針對的是OpenCV的imread操作Converts a PIL Image or numpy.ndarray (H x W x C) in the range[0, 255] to a torch.FloatTensor of shape (C x H x W) in the range [0.0, 1.0]if the PIL Image belongs to one of the modes (L, LA, P, I, F, RGB, YCbCr, RGBA, CMYK, 1)or if the numpy.ndarray has dtype = np.uint8In the other cases, tensors are returned without scaling... note::Because the input image is scaled to [0.0, 1.0], this transformation should not be used whentransforming target image masks. See the `references`_ for implementing the transforms for image masks... _references: https://github.com/pytorch/vision/tree/main/references/segmentation"""

Ⅰ通過PIL的Image讀取圖片類型為PIL,使用ToTensor將圖片類型轉換為tensor,并通過add_image上傳tensorbord

import cv2 as cv
from PIL import Image
from torch.utils.tensorboard import SummaryWriter
from torchvision import transformsimg_path = "G:/PyCharm/workspace/learning_pytorch/dataset/a/3.jpg"# 通過Image打開的圖片類型為PIL
img = Image.open(img_path)
print(type(img))#<class 'PIL.JpegImagePlugin.JpegImageFile'># # 通過opencv的imread打開的圖片類型為numpy.ndarray
# img = cv.imread(img_path)
# print(type(img))#<class 'numpy.ndarray'>#通過transforms的ToTensor即可轉換為Tensor類型
tensor_trans = transforms.ToTensor()#創建ToTensor對象
tensor_img = tensor_trans(img)#Ctrl+p  查看需要傳入的參數,傳入圖片
print(type(tensor_img))#<class 'torch.Tensor'>
print(tensor_img.shape)#torch.Size([3, 299, 300])"""
add_image()要求:
①圖片類型為torch.Tensor, numpy.array, or string/blobname
②圖片尺寸規格為(3, H, W),若不一樣需要通過dataformats參數進行聲明
很顯然tensor_img滿足add_image的基本要求,可以直接傳入使用
"""writer = SummaryWriter("y_log")writer.add_image("tensor_img",tensor_img)#默認從0開始
writer.close()

在Terminal下運行tensorboard --logdir=y_log --port=2312,logdir為打開事件文件的路徑,port為指定端口打開;
通過指定端口2312進行打開tensorboard,若不設置port參數,默認通過6006端口進行打開。
在這里插入圖片描述
點擊該鏈接或者復制鏈接到瀏覽器打開即可
在這里插入圖片描述

Ⅱ為啥神經網絡中傳入的圖片數據類型必須是tensor?

打開Python Console,將上面的代碼復制運行
可以看到tensor包含grad梯度等信息,也就是tensor數據類型包裝了神經網絡所需要的一些參數信息
在這里插入圖片描述

Ⅲ__call__方法的作用

transform.py文件中的ToTensor類下面有一個__call__方法,接下來進行探討下該方法的作用是啥
在這里插入圖片描述

class Band:def __call__(self, bandname):print("call-"+bandname)def music_band(self,bandname):print("hello-"+bandname)band = Band()
band("beyond")#call-beyond
band.music_band("huangjiaju")#hello-huangjiaju

由結果可以看出,在Band類中,若直接對其對象傳入參數,會使用__call__方法;若指定某個方法名稱才會使用某方法。其實__call__方法起到默認優先考慮的效果而已。

三、ToPILImage類

看下文檔給的使用說明
Ctrl+P:顯示方法所需要的參數
在這里插入圖片描述

    """Convert a tensor or an ndarray to PIL Image. This transform does not support torchscript.
#將tensor、ndarray 轉換為PIL類型Converts a torch.*Tensor of shape C x H x W or a numpy ndarray of shapeH x W x C to a PIL Image while preserving the value range.Args:mode (`PIL.Image mode`_): color space and pixel depth of input data (optional).If ``mode`` is ``None`` (default) there are some assumptions made about the input data:- If the input has 4 channels, the ``mode`` is assumed to be ``RGBA``.- If the input has 3 channels, the ``mode`` is assumed to be ``RGB``.- If the input has 2 channels, the ``mode`` is assumed to be ``LA``.- If the input has 1 channel, the ``mode`` is determined by the data type (i.e ``int``, ``float``,``short``)... _PIL.Image mode: https://pillow.readthedocs.io/en/latest/handbook/concepts.html#concept-modes"""

通過ToPILImage方法可將tensor、ndarray類型圖片轉換為PIL類型

from torch.utils.tensorboard import SummaryWriter
from PIL import Image
import cv2 as cv 
import numpy as np
from torchvision import transformsimg_path = "G:/PyCharm/workspace/learning_pytorch/dataset/a/3.jpg"img = cv.imread(img_path)
type(img)#numpy.ndarrayPIL = transforms.ToPILImage()
PIL_img = PIL(img)
type(PIL_img)#PIL.Image.ImagePIL_img.show()#展示照片cv.imshow("img",img)#展示照片
cv.waitKey(0)
cv.destroyAllWindows()

四、Normalize類

看下文檔給的使用說明
Ctrl+P:顯示方法所需要的參數
在這里插入圖片描述

    """Normalize a tensor image with mean and standard deviation.
#用均值和標準差歸一化張量圖像,也就是歸一化操作This transform does not support PIL Image.Given mean: ``(mean[1],...,mean[n])`` and std: ``(std[1],..,std[n])`` for ``n``channels, this transform will normalize each channel of the input``torch.*Tensor`` i.e.,``output[channel] = (input[channel] - mean[channel]) / std[channel]``.. note::This transform acts out of place, i.e., it does not mutate the input tensor.Args:mean (sequence): Sequence of means for each channel.std (sequence): Sequence of standard deviations for each channel.inplace(bool,optional): Bool to make this operation in-place."""

使用要求:必須是tensor類型,由文檔介紹可得:

output[channel] = (input[channel] - mean[channel]) / std[channel]

from PIL import Image
from torch.utils.tensorboard import SummaryWriter
import cv2 as cv
import numpy as np
from torchvision import transformswrite = SummaryWriter("y_log")img_path = "dataset/b/6.jpg"img = cv.imread(img_path)
print(type(img))#<class 'numpy.ndarray'>
print(img.size)#61375
print(img.shape)#(375, 499, 3)trans_tensor = transforms.ToTensor()
img_tensor = trans_tensor(img)
print(type(img_tensor))#<class 'torch.Tensor'>print(img_tensor[0][0][0])#tensor(0.5255)
trans_normalize = transforms.Normalize([0.5, 0.5, 0.5], [0.5, 0.5, 0.5])
img_normalize = trans_normalize(img_tensor)
print(img_normalize[0][0][0])#tensor(0.0510)#公式:output[channel] = (input[channel] - mean[channel]) / std[channel]
#(0.5255-0.5)/0.5 = 0.051print(img_normalize.shape)#torch.Size([3, 375, 499])
#shape符合add_image的要求(C,H,W),可直接傳入使用write.add_image("img_normalize",img_normalize)write.close()

在Terminal下運行tensorboard --logdir=y_log --port=2312,logdir為打開事件文件的路徑,port為指定端口打開;
通過指定端口2312進行打開tensorboard,若不設置port參數,默認通過6006端口進行打開。
在這里插入圖片描述
點擊該鏈接或者復制鏈接到瀏覽器打開即可
在這里插入圖片描述

五、Resize類

看下文檔給的使用說明
Ctrl+P:顯示方法所需要的參數
在這里插入圖片描述

    """Resize the input image to the given size.
#將輸入圖像調整為給定大小,也就是對輸入圖像進行尺寸變換If the image is torch Tensor, it is expectedto have [..., H, W] shape, where ... means an arbitrary number of leading dimensions.. warning::The output image might be different depending on its type: when downsampling, the interpolation of PIL imagesand tensors is slightly different, because PIL applies antialiasing. This may lead to significant differencesin the performance of a network. Therefore, it is preferable to train and serve a model with the same inputtypes. See also below the ``antialias`` parameter, which can help making the output of PIL images and tensorscloser.Args:size (sequence or int): Desired output size. If size is a sequence like(h, w), output size will be matched to this. If size is an int,smaller edge of the image will be matched to this number.i.e, if height > width, then image will be rescaled to(size * height / width, size).
#需要給出要裁剪成的形狀(h,w),若只給一個數,則默認裁剪成一個正方形.. note::In torchscript mode size as single int is not supported, use a sequence of length 1: ``[size, ]``.interpolation (InterpolationMode): Desired interpolation enum defined by:class:`torchvision.transforms.InterpolationMode`. Default is ``InterpolationMode.BILINEAR``.If input is Tensor, only ``InterpolationMode.NEAREST``, ``InterpolationMode.BILINEAR`` and``InterpolationMode.BICUBIC`` are supported.For backward compatibility integer values (e.g. ``PIL.Image.NEAREST``) are still acceptable.max_size (int, optional): The maximum allowed for the longer edge ofthe resized image: if the longer edge of the image is greaterthan ``max_size`` after being resized according to ``size``, thenthe image is resized again so that the longer edge is equal to``max_size``. As a result, ``size`` might be overruled, i.e thesmaller edge may be shorter than ``size``. This is only supportedif ``size`` is an int (or a sequence of length 1 in torchscriptmode).antialias (bool, optional): antialias flag. If ``img`` is PIL Image, the flag is ignored and anti-aliasis always used. If ``img`` is Tensor, the flag is False by default and can be set to True for``InterpolationMode.BILINEAR`` only mode. This can help making the output for PIL images and tensorscloser... warning::There is no autodiff support for ``antialias=True`` option with input ``img`` as Tensor."""

輸入類型為PIL圖片,通過Resize轉換大小,再通過ToTensor轉換為tensor類型上傳tensorboard

from PIL import Image
from torch.utils.tensorboard import SummaryWriter
import cv2 as cv
import numpy as np
from torchvision import transformswrite = SummaryWriter("y_log")img_path = "dataset/b/6.jpg"img = Image.open(img_path)
print(type(img))#<class 'PIL.JpegImagePlugin.JpegImageFile'>
print(img.size)#(499, 375)   原始圖片的大小
trans_resize = transforms.Resize((300,300))
img_PIL_resize = trans_resize(img)#進行裁剪
print(img_PIL_resize)#<PIL.Image.Image image mode=RGB size=300x300 at 0x1FDDC07C9B0>  原圖像已經變成了(300,300),但還是PIL類型#要想上傳到tensorboard上,必須是tensor、numpy.array類型,這里通過ToTensor方法轉換為tensor
trans_tensor = transforms.ToTensor()
img_tensor = trans_tensor(img_PIL_resize)
print(type(img_tensor))#<class 'torch.Tensor'>write.add_image("img_PIL_resize",img_tensor)#默認從0開始write.close()

在Terminal下運行tensorboard --logdir=y_log --port=2312,logdir為打開事件文件的路徑,port為指定端口打開;
通過指定端口2312進行打開tensorboard,若不設置port參數,默認通過6006端口進行打開。
在這里插入圖片描述
點擊該鏈接或者復制鏈接到瀏覽器打開即可
在這里插入圖片描述
與下面的歸一化之后的圖像相比,大小很明顯發生了變化

六、Compose類

看下文檔給的使用說明
Ctrl+P:顯示方法所需要的參數
在這里插入圖片描述

    """Composes several transforms together. This transform does not support torchscript.
#組合一些transforms一起使用Please, see the note below.Args:transforms (list of ``Transform`` objects): list of transforms to compose.Example:>>> transforms.Compose([>>>     transforms.CenterCrop(10),#先對圖片進行一次中心裁剪>>>     transforms.PILToTensor(),#再對圖片轉換為tensor>>>     transforms.ConvertImageDtype(torch.float),#之后再將圖像轉換為dtype,如果需要,縮放其值>>> ])#一個Compose可以實現多次的transforms對圖片進行操作.. note::In order to script the transformations, please use ``torch.nn.Sequential`` as below.>>> transforms = torch.nn.Sequential(>>>     transforms.CenterCrop(10),>>>     transforms.Normalize((0.485, 0.456, 0.406), (0.229, 0.224, 0.225)),>>> )>>> scripted_transforms = torch.jit.script(transforms)Make sure to use only scriptable transformations, i.e. that work with ``torch.Tensor``, does not require`lambda` functions or ``PIL.Image``."""

說白了就是組合多種transform操作

from PIL import Image
from torch.utils.tensorboard import SummaryWriter
import cv2 as cv
import numpy as np
from torchvision import transformswriter = SummaryWriter('y_log')img_path = "dataset/b/6.jpg"img = Image.open(img_path)
print(type(img))#<class 'PIL.JpegImagePlugin.JpegImageFile'>
print(img.size)#(499, 375)   原始圖片的大小
#①剪切尺寸
trans_resize = transforms.Resize((300,300))
img_PIL_resize = trans_resize(img)#進行裁剪
print(img_PIL_resize)#<PIL.Image.Image image mode=RGB size=300x300 at 0x1FDDC07C9B0>  原圖像已經變成了(300,300),但還是PIL類型#②PIL轉Tensor
trans_tensor = transforms.ToTensor()trans_compose = transforms.Compose([trans_resize,trans_tensor])
#Compose參數都是transform對象,且第一個輸出必須滿足第二個輸入
#trans_resize為Resize對象,最后輸出為PIL類型
#trans_tensor為ToTensor對象,輸入為PIL,輸出為tensorimg_all = trans_compose(img)
#因為最后輸出為tensor,故才可以通過add_image上傳至tensorboardwriter.add_image("compose_img",img_all)
writer.close()

在Terminal下運行tensorboard --logdir=y_log --port=2312,logdir為打開事件文件的路徑,port為指定端口打開;
通過指定端口2312進行打開tensorboard,若不設置port參數,默認通過6006端口進行打開。
在這里插入圖片描述
點擊該鏈接或者復制鏈接到瀏覽器打開即可,該操作其實就是將Resize和ToTensor進行了整合使用而已
在這里插入圖片描述

八、RandomCrop類

看下文檔給的使用說明
Ctrl+P:顯示方法所需要的參數
在這里插入圖片描述

    """Crop the given image at a random location.If the image is torch Tensor, it is expectedto have [..., H, W] shape, where ... means an arbitrary number of leading dimensions,but if non-constant padding is used, the input is expected to have at most 2 leading dimensionsArgs:size (sequence or int): Desired output size of the crop. If size is anint instead of sequence like (h, w), a square crop (size, size) ismade. If provided a sequence of length 1, it will be interpreted as (size[0], size[0]).padding (int or sequence, optional): Optional padding on each borderof the image. Default is None. If a single int is provided thisis used to pad all borders. If sequence of length 2 is provided this is the paddingon left/right and top/bottom respectively. If a sequence of length 4 is providedthis is the padding for the left, top, right and bottom borders respectively.
#需要給出要裁剪成的形狀(h,w),若只給一個數,則默認裁剪成一個正方形.. note::In torchscript mode padding as single int is not supported, use a sequence oflength 1: ``[padding, ]``.pad_if_needed (boolean): It will pad the image if smaller than thedesired size to avoid raising an exception. Since cropping is doneafter padding, the padding seems to be done at a random offset.fill (number or str or tuple): Pixel fill value for constant fill. Default is 0. If a tuple oflength 3, it is used to fill R, G, B channels respectively.This value is only used when the padding_mode is constant.Only number is supported for torch Tensor.Only int or str or tuple value is supported for PIL Image.padding_mode (str): Type of padding. Should be: constant, edge, reflect or symmetric.Default is constant.- constant: pads with a constant value, this value is specified with fill- edge: pads with the last value at the edge of the image.If input a 5D torch Tensor, the last 3 dimensions will be padded instead of the last 2- reflect: pads with reflection of image without repeating the last value on the edge.For example, padding [1, 2, 3, 4] with 2 elements on both sides in reflect modewill result in [3, 2, 1, 2, 3, 4, 3, 2]- symmetric: pads with reflection of image repeating the last value on the edge.For example, padding [1, 2, 3, 4] with 2 elements on both sides in symmetric modewill result in [2, 1, 1, 2, 3, 4, 4, 3]"""

說白了就是隨機對圖片進行裁剪

from PIL import Image
from torch.utils.tensorboard import SummaryWriter
import cv2 as cv
import numpy as np
from torchvision import transformswriter = SummaryWriter('y_log')img_path = "dataset/b/6.jpg"img = Image.open(img_path)
print(type(img))#<class 'PIL.JpegImagePlugin.JpegImageFile'>
print(img.size)#(499, 375)   原始圖片的大小
#①隨機剪切尺寸
trans_random = transforms.RandomCrop((200,250))#(h,w)
img_PIL_random = trans_random(img)#隨機進行裁剪
print(img_PIL_random)#<PIL.Image.Image image mode=RGB size=250,200 at 0x1FDDC07C9B0>  
#PIL輸出為(w,h),即原圖像已經變成了(h,w),(200,250),但還是PIL類型#②PIL轉Tensor
trans_tensor = transforms.ToTensor()trans_compose = transforms.Compose([trans_random,trans_tensor])
#Compose參數都是transform對象,且第一個輸出必須滿足第二個輸入
#trans_resize為Resize對象,最后輸出為PIL類型
#trans_tensor為ToTensor對象,輸入為PIL,輸出為tensorfor i in range(10):img_randomcrop = trans_compose(img)# 因為最后輸出為tensor,故才可以通過add_image上傳至tensorboardwriter.add_image("img_randomcrop",img_randomcrop,i)writer.close()

在Terminal下運行tensorboard --logdir=y_log --port=2312,logdir為打開事件文件的路徑,port為指定端口打開;
通過指定端口2312進行打開tensorboard,若不設置port參數,默認通過6006端口進行打開。
在這里插入圖片描述
點擊該鏈接或者復制鏈接到瀏覽器打開即可
在這里插入圖片描述

七、CenterCrop類

看下文檔給的使用說明
Ctrl+P:顯示方法所需要的參數
在這里插入圖片描述

    """Crops the given image at the center.
#對圖像進行中心裁剪If the image is torch Tensor, it is expectedto have [..., H, W] shape, where ... means an arbitrary number of leading dimensions.If image size is smaller than output size along any edge, image is padded with 0 and then center cropped.Args:size (sequence or int): Desired output size of the crop. If size is anint instead of sequence like (h, w), a square crop (size, size) ismade. If provided a sequence of length 1, it will be interpreted as (size[0], size[0])."""

說白了就是對圖像進行中心裁剪

from PIL import Image
from torch.utils.tensorboard import SummaryWriter
import cv2 as cv
import numpy as np
from torchvision import transformswriter = SummaryWriter('y_log')img_path = "dataset/b/6.jpg"img = Image.open(img_path)
print(type(img))#<class 'PIL.JpegImagePlugin.JpegImageFile'>
print(img.size)#(499, 375)   原始圖片的大小
#①中間剪切尺寸
trans_center = transforms.CenterCrop((200,250))#(h,w)
img_PIL_center = trans_center(img)#隨機進行裁剪
print(img_PIL_center)#<PIL.Image.Image image mode=RGB size=250,200 at 0x1FDDC07C9B0>
#PIL輸出為(w,h),即原圖像已經變成了(h,w),(200,250),但還是PIL類型#②PIL轉Tensor
trans_tensor = transforms.ToTensor()trans_compose = transforms.Compose([trans_center,trans_tensor])
#Compose參數都是transform對象,且第一個輸出必須滿足第二個輸入
#trans_resize為Resize對象,最后輸出為PIL類型
#trans_tensor為ToTensor對象,輸入為PIL,輸出為tensorimg_centercrop = trans_compose(img)writer.add_image("img_centercrop",img_centercrop)
writer.close()

在Terminal下運行tensorboard --logdir=y_log --port=2312,logdir為打開事件文件的路徑,port為指定端口打開;
通過指定端口2312進行打開tensorboard,若不設置port參數,默認通過6006端口進行打開。
在這里插入圖片描述
點擊該鏈接或者復制鏈接到瀏覽器打開即可
在這里插入圖片描述

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/news/377593.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/377593.shtml
英文地址,請注明出處:http://en.pswp.cn/news/377593.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

leetcode 134. 加油站 思考分析

目錄題目1、暴力法&#xff0c;雙層遍歷2、貪心題目 在一條環路上有 N 個加油站&#xff0c;其中第 i 個加油站有汽油 gas[i] 升。 你有一輛油箱容量無限的的汽車&#xff0c;從第 i 個加油站開往第 i1 個加油站需要消耗汽油 cost[i] 升。你從其中的一個加油站出發&#xff0…

單鏈線性表的實現

//函數結果狀態代碼#define TRUE 1 #define FALSE 0 #define OK 1 #define ERROR 0 #define INFEASIBLE -1 #define OVERFLOW -2 //Status是函數的類型&#xff0c;其值是函數結果狀態代碼 typedef int Status; typedef int ElemType;…

時間模塊,帶Python示例

Python時間模塊 (Python time Module) The time module is a built-in module in Python and it has various functions that require to perform more operations on time. This is one of the best modules in Python that used to solve various real-life time-related pro…

五、torchvision

一、下載CIFAR-10數據集 CIFAR-10數據集官網 通過閱讀官網給的解釋可以大概了解到&#xff0c;一共6w張圖片&#xff0c;每張圖片大小為3232&#xff0c;5w張訓練圖像&#xff0c;1w張測試圖像&#xff0c;一共由十大類圖像。 CIFAR10官網使用文檔 torchvision.datasets.CIF…

leetcode 69. x 的平方根 思考分析

題目 實現 int sqrt(int x) 函數。 計算并返回 x 的平方根&#xff0c;其中 x 是非負整數。 由于返回類型是整數&#xff0c;結果只保留整數的部分&#xff0c;小數部分將被舍去。 示例 1: 輸入: 4 輸出: 2 示例 2: 輸入: 8 輸出: 2 說明: 8 的平方根是 2.82842…, 由于返回…

背包問題 小灰_小背包問題

背包問題 小灰Prerequisites: Algorithm for fractional knapsack problem 先決條件&#xff1a; 分數背包問題算法 Here, we are discussing the practical implementation of the fractional knapsack problem. It can be solved using the greedy approach and in fraction…

360瀏覽器兼容問題

360瀏覽器兼容問題 360瀏覽器又是一大奇葩&#xff0c;市場份額大&#xff0c;讓我們不得不也對他做些兼容性處理。 360瀏覽器提供了兩種瀏覽模式&#xff0c;極速模式和兼容模式&#xff0c;極速模式下是webkit內核的處理模式&#xff0c;兼容模式下是與IE內核相同的處理模式。…

轉 設計師也需要了解的一些前端知識

一、常見視覺效果是如何實現的 一些事 關于文字效果 互聯網的一些事 文字自身屬性相關的效果css中都是有相對應的樣式的&#xff0c;如字號、行高、加粗、傾斜、下劃線等&#xff0c;但是一些特殊的效果&#xff0c;主要表現為ps中圖層樣式中的效果&#xff0c;css是無能為力的…

六、DataLoader

一、DataLoader參數解析 DataLoader官網使用手冊 參數描述dataset說明數據集所在的位置、數據總數等batch_size每次取多少張圖片shuffleTrue亂序、False順序(默認)samplerbatch_samplernum_workers多進程&#xff0c;默認為0采用主進程加載數據collate_fnpin_memorydrop_las…

單調棧 leetcode整理(一)

目錄單調棧知識402. 移掉K位數字1673. 找出最具競爭力的子序列316. 去除重復字母&#xff08;1081. 不同字符的最小子序列&#xff09;321. 拼接最大數單調棧知識 單調棧就是一個內部元素有序的棧&#xff08;大->小 or 小->大&#xff09;&#xff0c;但是只用到它的一…

數字簽名 那些密碼技術_密碼學中的數字簽名

數字簽名 那些密碼技術A signature is usually used to bind signatory to the message. The digital signature is thus a technique that binds a person or the entity to the digital data. This binding ensures that the person sending the data is solely responsible …

七、torch.nn

一、神經網絡模塊 進入到PyTorch的torch.nnAPI學習頁面 PyTorch提供了很多的神經網絡方面的模塊&#xff0c;NN就是Neural Networks的簡稱 二、Containers torch.nn下的Containers 一共有六個模塊&#xff0c;最常用的就是Module模塊&#xff0c;看解釋可以知道&#xff0c…

Java多線程初學者指南(8):從線程返回數據的兩種方法

本文介紹學習Java多線程中需要學習的從線程返回數據的兩種方法。從線程中返回數據和向線程傳遞數據類似。也可以通過類成員以及回調函數來返回數據。原文鏈接 從線程中返回數據和向線程傳遞數據類似。也可以通過類成員以及回調函數來返回數據。但類成員在返回數據和傳遞數據時有…

【C++進階】 遵循TDD原則,實現平面向量類(Vec2D)

目錄1、明確要實現的類的方法以及成員函數2、假設已經編寫Vec2D&#xff0c;根據要求&#xff0c;寫出測試代碼3、編寫平面向量類Vec2D,并進行測試4、完整代碼5、最終結果1、明確要實現的類的方法以及成員函數 考慮到效率問題&#xff0c;我們一般將函數的參數設置為引用類型。…

Keilc的中斷號計算方法

中斷號碼 (中斷向量-3)/8轉載于:https://www.cnblogs.com/yuqilihualuo/p/3423634.html

md5模式 簽名_MD的完整形式是什么?

md5模式 簽名醫師&#xff1a;醫學博士/常務董事 (MD: Doctor of Medicine / Managing Director) 1)醫學博士&#xff1a;醫學博士 (1) MD: Doctor of Medicine) MD is an abbreviation of a Doctor of Medicine degree. In the field of Medicine, it is the main academic de…

八、卷積層

一、Conv2d torch.nn.Conv2d官網文檔 torch.nn.Conv2d(in_channels, out_channels, kernel_size, stride1, padding0, dilation1, groups1, biasTrue, padding_modezeros, deviceNone, dtypeNone) 參數解釋官網詳情說明in_channels輸入的通道數&#xff0c;如果是彩色照片通道…

HTMl5結構元素:header

頁眉header 頁眉將是頁面加載的第一個元素&#xff0c;包含了站點的標題、logo、網站導航等。<header> <div class"container_16"> <div class"logo"> <h1><a href"index.html"><strong>Real</st…

【C++grammar】左值、右值和將亡值

目錄C03的左值和右值C11的左值和右值將亡值在C03中就有相關的概念 C03的左值和右值 通俗的理解&#xff1a; (1) 能放在等號左邊的是lvalue (2) 只能放在等號右邊的是rvalue (3) lvalue可以作為rvalue使用 對于第三點可以舉個例子&#xff1a; int x ; x 6; //x是左值&#…

scala字符串的拉鏈操作_在Scala中對字符串進行操作

scala字符串的拉鏈操作Scala字符串操作 (Scala strings operation) A string is a very important datatype in Scala. This is why there are a lot of operations that can be done on the string object. Since the regular operations like addition, subtraction is not v…