四、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.mzph.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…