深度学习(31)——DeformableDETR(2)

news2024/11/26 0:52:36

深度学习(31)——DeformableDETR(2)

文章目录

  • 深度学习(31)——DeformableDETR(2)
    • 1. `backbone`——Resnet50
    • 2. `neck`——Channel mapper
    • 3. `DeformableDETRHead`
    • 4. `DeformableDetrTransformer`
    • 5. `Transformer Encoder`
    • 6. `Transformer Decoder`
    • 7. `loss_single`

上一篇主要记录DeformableDETR的核心理论,这一篇主要记录mmcv中DeformableDETR的实现过程

针对一个batch的图片[B,3,W,H,],设置transformer的隐层维度为256,那么将会经历backbone提取特征,Transformer_Encoder,Transformer_Decoder。

1. backbone——Resnet50

  • Backbone用于提取图像特征,得到多个维度的特征
  • DeformableDETR中的backbone是Resnet50, 指定输出三层特征图(分别是C3-C5得到的feature map)
  • 最后输出是一个有三个特征图的列表,如下(neck的输入):

2. neck——Channel mapper

在这里插入图片描述
在这里插入图片描述

  • 将三个feature map经过三个1*1卷积变换为256的特征
  • 将最后一层特征 C5得到的经过3*3卷积变换成256的特征作为第四个特征
    在这里插入图片描述
  • 输出是一个tuple,其中有四个元素
    在这里插入图片描述

3. DeformableDETRHead

  • 输入是neck得到的长度为4的tuple(mlvl_feats)
  • 构建feature对应的mask和position_embedding
    在这里插入图片描述
    在这里插入图片描述
  • 中间有一个叫query_embedding的变量

4. DeformableDetrTransformer

  • 输入是每一层的特征图,padding的mask和每层的position embedding。注都是一一对应的
    【feature(1,256,96,125);mask(1,96,125);position_embedding(1,256,96,125)】
  • 将所有feature,mask和position embedding展开(flatten)
    【feature(1,96* 125,256);mask(1,96* 125);position_embedding(1,96* 125,256)】
  • 除了position_embedding,每个level还有自己的level_embedding(level_embedding是可学习的),最后每个position还要加上所在level的level_embedding
    在这里插入图片描述
  • 将所有level的feature,mask和pos_level_embedding分别都cat成一个,并记录每个level特征在新矩阵中的起始位置
  • 得到reference_points,可以理解为将图片分成H*W个像素点,每个像素点是一个reference_point,最后每个level都有属于自己的reference_point,将他们cat在一起就OK
  • 之后将feature和pos_level_embedding转化为(H*W,b,256)进入Encoder

5. Transformer Encoder

  • 有六层,每一层都是下面这样的一个block

BaseTransformerLayer(
(attentions): ModuleList(
(0): MultiScaleDeformableAttention(
(dropout): Dropout(p=0.1, inplace=False)
(sampling_offsets): Linear(in_features=256, out_features=256, bias=True)
(attention_weights): Linear(in_features=256, out_features=128, bias=True)
(value_proj): Linear(in_features=256, out_features=256, bias=True)
(output_proj): Linear(in_features=256, out_features=256, bias=True)
)
)
(ffns): ModuleList(
(0): FFN(
(activate): ReLU(inplace=True)
(layers): Sequential(
(0): Sequential(
(0): Linear(in_features=256, out_features=1024, bias=True)
(1): ReLU(inplace=True)
(2): Dropout(p=0.1, inplace=False)
)
(1): Linear(in_features=1024, out_features=256, bias=True)
(2): Dropout(p=0.1, inplace=False)
)
(dropout_layer): Identity()
)
)
(norms): ModuleList(
(0): LayerNorm((256,), eps=1e-05, elementwise_affine=True)
(1): LayerNorm((256,), eps=1e-05, elementwise_affine=True)
)
)

因为我跳不进去,模型就是上面说的。其实咱看config文件,这个6层什么的都是咱再config文件中定义好的。

encoder=dict(
                type='DetrTransformerEncoder',
                num_layers=6,
                transformerlayers=dict(
                    type='BaseTransformerLayer',
                    attn_cfgs=dict(
                        type='MultiScaleDeformableAttention', embed_dims=256),
                    feedforward_channels=1024,
                    ffn_dropout=0.1,
                    operation_order=('self_attn', 'norm', 'ffn', 'norm'))),
  • 核心来了,这个multi-sacleDeformableAttention是怎么做的呢?我跳不进去,我找了官网上的代码,放下面
class MultiScaleDeformableAttention(BaseModule):
    """An attention module used in Deformable-Detr.

    `Deformable DETR: Deformable Transformers for End-to-End Object Detection.
    <https://arxiv.org/pdf/2010.04159.pdf>`_.

    Args:
        embed_dims (int): The embedding dimension of Attention.
            Default: 256.
        num_heads (int): Parallel attention heads. Default: 8.
        num_levels (int): The number of feature map used in
            Attention. Default: 4.
        num_points (int): The number of sampling points for
            each query in each head. Default: 4.
        im2col_step (int): The step used in image_to_column.
            Default: 64.
        dropout (float): A Dropout layer on `inp_identity`.
            Default: 0.1.
        batch_first (bool): Key, Query and Value are shape of
            (batch, n, embed_dim)
            or (n, batch, embed_dim). Default to False.
        norm_cfg (dict): Config dict for normalization layer.
            Default: None.
        init_cfg (obj:`mmcv.ConfigDict`): The Config for initialization.
            Default: None.
    """

    def __init__(self,
                 embed_dims: int = 256,
                 num_heads: int = 8,
                 num_levels: int = 4,
                 num_points: int = 4,
                 im2col_step: int = 64,
                 dropout: float = 0.1,
                 batch_first: bool = False,
                 norm_cfg: Optional[dict] = None,
                 init_cfg: Optional[mmcv.ConfigDict] = None):
        super().__init__(init_cfg)
        if embed_dims % num_heads != 0:
            raise ValueError(f'embed_dims must be divisible by num_heads, '
                             f'but got {embed_dims} and {num_heads}')
        dim_per_head = embed_dims // num_heads
        self.norm_cfg = norm_cfg
        self.dropout = nn.Dropout(dropout)
        self.batch_first = batch_first

        # you'd better set dim_per_head to a power of 2
        # which is more efficient in the CUDA implementation
        def _is_power_of_2(n):
            if (not isinstance(n, int)) or (n < 0):
                raise ValueError(
                    'invalid input for _is_power_of_2: {} (type: {})'.format(
                        n, type(n)))
            return (n & (n - 1) == 0) and n != 0

        if not _is_power_of_2(dim_per_head):
            warnings.warn(
                "You'd better set embed_dims in "
                'MultiScaleDeformAttention to make '
                'the dimension of each attention head a power of 2 '
                'which is more efficient in our CUDA implementation.')

        self.im2col_step = im2col_step
        self.embed_dims = embed_dims
        self.num_levels = num_levels
        self.num_heads = num_heads
        self.num_points = num_points
        self.sampling_offsets = nn.Linear(
            embed_dims, num_heads * num_levels * num_points * 2)
        self.attention_weights = nn.Linear(embed_dims,
                                           num_heads * num_levels * num_points)
        self.value_proj = nn.Linear(embed_dims, embed_dims)
        self.output_proj = nn.Linear(embed_dims, embed_dims)
        self.init_weights()

    def init_weights(self) -> None:
        """Default initialization for Parameters of Module."""
        constant_init(self.sampling_offsets, 0.)
        device = next(self.parameters()).device
        thetas = torch.arange(
            self.num_heads, dtype=torch.float32,
            device=device) * (2.0 * math.pi / self.num_heads)
        grid_init = torch.stack([thetas.cos(), thetas.sin()], -1)
        grid_init = (grid_init /
                     grid_init.abs().max(-1, keepdim=True)[0]).view(
                         self.num_heads, 1, 1,
                         2).repeat(1, self.num_levels, self.num_points, 1)
        for i in range(self.num_points):
            grid_init[:, :, i, :] *= i + 1

        self.sampling_offsets.bias.data = grid_init.view(-1)
        constant_init(self.attention_weights, val=0., bias=0.)
        xavier_init(self.value_proj, distribution='uniform', bias=0.)
        xavier_init(self.output_proj, distribution='uniform', bias=0.)
        self._is_init = True

    @no_type_check
    @deprecated_api_warning({'residual': 'identity'},
                            cls_name='MultiScaleDeformableAttention')
    def forward(self,
                query: torch.Tensor,
                key: Optional[torch.Tensor] = None,
                value: Optional[torch.Tensor] = None,
                identity: Optional[torch.Tensor] = None,
                query_pos: Optional[torch.Tensor] = None,
                key_padding_mask: Optional[torch.Tensor] = None,
                reference_points: Optional[torch.Tensor] = None,
                spatial_shapes: Optional[torch.Tensor] = None,
                level_start_index: Optional[torch.Tensor] = None,
                **kwargs) -> torch.Tensor:
        """Forward Function of MultiScaleDeformAttention.

        Args:
            query (torch.Tensor): Query of Transformer with shape
                (num_query, bs, embed_dims).
            key (torch.Tensor): The key tensor with shape
                `(num_key, bs, embed_dims)`.
            value (torch.Tensor): The value tensor with shape
                `(num_key, bs, embed_dims)`.
            identity (torch.Tensor): The tensor used for addition, with the
                same shape as `query`. Default None. If None,
                `query` will be used.
            query_pos (torch.Tensor): The positional encoding for `query`.
                Default: None.
            key_padding_mask (torch.Tensor): ByteTensor for `query`, with
                shape [bs, num_key].
            reference_points (torch.Tensor):  The normalized reference
                points with shape (bs, num_query, num_levels, 2),
                all elements is range in [0, 1], top-left (0,0),
                bottom-right (1, 1), including padding area.
                or (N, Length_{query}, num_levels, 4), add
                additional two dimensions is (w, h) to
                form reference boxes.
            spatial_shapes (torch.Tensor): Spatial shape of features in
                different levels. With shape (num_levels, 2),
                last dimension represents (h, w).
            level_start_index (torch.Tensor): The start index of each level.
                A tensor has shape ``(num_levels, )`` and can be represented
                as [0, h_0*w_0, h_0*w_0+h_1*w_1, ...].

        Returns:
            torch.Tensor: forwarded results with shape
            [num_query, bs, embed_dims].
        """

        if value is None:
            value = query

        if identity is None:
            identity = query
        if query_pos is not None:
            query = query + query_pos
        if not self.batch_first:
            # change to (bs, num_query ,embed_dims)
            query = query.permute(1, 0, 2)
            value = value.permute(1, 0, 2)

        bs, num_query, _ = query.shape
        bs, num_value, _ = value.shape
        assert (spatial_shapes[:, 0] * spatial_shapes[:, 1]).sum() == num_value

        value = self.value_proj(value) # 经过一个linear
        if key_padding_mask is not None:
            value = value.masked_fill(key_padding_mask[..., None], 0.0)
        value = value.view(bs, num_value, self.num_heads, -1)# 最后的256维度的向量分为多头进行256=4*64
        sampling_offsets = self.sampling_offsets(query).view(
            bs, num_query, self.num_heads, self.num_levels, self.num_points, 2)# 使用一个linear(in:256,out:num_heads*num_levels*num_points*2)学习得到每个reference_point的四个采样点相对于该点的偏移
        attention_weights = self.attention_weights(query).view(
            bs, num_query, self.num_heads, self.num_levels * self.num_points)# 使用linear(in:256,out:num_heads * num_levels * num_points)得到注意力机制的权重
        attention_weights = attention_weights.softmax(-1)

        attention_weights = attention_weights.view(bs, num_query,
                                                   self.num_heads,
                                                   self.num_levels,
                                                   self.num_points)
        if reference_points.shape[-1] == 2:
            offset_normalizer = torch.stack(
                [spatial_shapes[..., 1], spatial_shapes[..., 0]], -1)
            sampling_locations = reference_points[:, :, None, :, None, :] \
                + sampling_offsets \
                / offset_normalizer[None, None, None, :, None, :]
        elif reference_points.shape[-1] == 4:
            sampling_locations = reference_points[:, :, None, :, None, :2] \
                + sampling_offsets / self.num_points \
                * reference_points[:, :, None, :, None, 2:] \
                * 0.5
        else:
            raise ValueError(
                f'Last dim of reference_points must be'
                f' 2 or 4, but get {reference_points.shape[-1]} instead.')
        if ((IS_CUDA_AVAILABLE and value.is_cuda)
                or (IS_MLU_AVAILABLE and value.is_mlu)):
            output = MultiScaleDeformableAttnFunction.apply(
                value, spatial_shapes, level_start_index, sampling_locations,
                attention_weights, self.im2col_step)
        else:
            output = multi_scale_deformable_attn_pytorch(
                value, spatial_shapes, sampling_locations, attention_weights)

        output = self.output_proj(output)

        if not self.batch_first:
            # (num_query, bs ,embed_dims)
            output = output.permute(1, 0, 2)

        return self.dropout(output) + identity

附上我的浅薄理解

  • 首先在encoder部分,query是feature,key和value都是None,所以在forward过程中,value直接等于query,为了后面做残差连接将query复制给了identity,之后query就要变成自身与位置编码的和了【开始变了哦,这时的query就和value不同了

  • 将query连一个linear学习得到每个reference_point的采样点偏移量(sample-offset)

  • 将query连一个linear学习得到每个reference_point和四个采样点之间的相关性(attention weight)

    得到这些之后就是计算了
    在这里插入图片描述

def multi_scale_deformable_attn_pytorch(
        value: torch.Tensor, value_spatial_shapes: torch.Tensor,
        sampling_locations: torch.Tensor,
        attention_weights: torch.Tensor) -> torch.Tensor:
    """CPU version of multi-scale deformable attention.

    Args:
        value (torch.Tensor): The value has shape
            (bs, num_keys, num_heads, embed_dims//num_heads)
        value_spatial_shapes (torch.Tensor): Spatial shape of
            each feature map, has shape (num_levels, 2),
            last dimension 2 represent (h, w)
        sampling_locations (torch.Tensor): The location of sampling points,
            has shape
            (bs ,num_queries, num_heads, num_levels, num_points, 2),
            the last dimension 2 represent (x, y).
        attention_weights (torch.Tensor): The weight of sampling points used
            when calculate the attention, has shape
            (bs ,num_queries, num_heads, num_levels, num_points),

    Returns:
        torch.Tensor: has shape (bs, num_queries, embed_dims)
    """

    bs, _, num_heads, embed_dims = value.shape
    _, num_queries, num_heads, num_levels, num_points, _ =\
        sampling_locations.shape
    value_list = value.split([H_ * W_ for H_, W_ in value_spatial_shapes],
                             dim=1)
    sampling_grids = 2 * sampling_locations - 1
    sampling_value_list = []
    for level, (H_, W_) in enumerate(value_spatial_shapes):
        # bs, H_*W_, num_heads, embed_dims ->
        # bs, H_*W_, num_heads*embed_dims ->
        # bs, num_heads*embed_dims, H_*W_ ->
        # bs*num_heads, embed_dims, H_, W_
        value_l_ = value_list[level].flatten(2).transpose(1, 2).reshape(
            bs * num_heads, embed_dims, H_, W_)
        # bs, num_queries, num_heads, num_points, 2 ->
        # bs, num_heads, num_queries, num_points, 2 ->
        # bs*num_heads, num_queries, num_points, 2
        sampling_grid_l_ = sampling_grids[:, :, :,
                                          level].transpose(1, 2).flatten(0, 1)
        # bs*num_heads, embed_dims, num_queries, num_points
        sampling_value_l_ = F.grid_sample(
            value_l_,
            sampling_grid_l_,
            mode='bilinear',
            padding_mode='zeros',
            align_corners=False)
        sampling_value_list.append(sampling_value_l_)
    # (bs, num_queries, num_heads, num_levels, num_points) ->
    # (bs, num_heads, num_queries, num_levels, num_points) ->
    # (bs, num_heads, 1, num_queries, num_levels*num_points)
    attention_weights = attention_weights.transpose(1, 2).reshape(
        bs * num_heads, 1, num_queries, num_levels * num_points)
    output = (torch.stack(sampling_value_list, dim=-2).flatten(-2) *
              attention_weights).sum(-1).view(bs, num_heads * embed_dims,
                                              num_queries)
    return output.transpose(1, 2).contiguous()
  • 之后就是经过FFN和LN,一个block完成,这样的过程重复6次得到output作为encoder的最终输出记为memory
  • 之后处理定义的object_query,经过一个linear层得到300个object的reference_point

6. Transformer Decoder

  • 进入decoder的时候query是object_query,value是encoder得到的memory
  • Decoder的网络结构也是6个相同的模块

DetrTransformerDecoderLayer(
(attentions): ModuleList(
(0): MultiheadAttention(
(attn): MultiheadAttention(
(out_proj): NonDynamicallyQuantizableLinear(in_features=256, out_features=256, bias=True)
)
(proj_drop): Dropout(p=0.0, inplace=False)
(dropout_layer): Dropout(p=0.1, inplace=False)
)
(1): MultiScaleDeformableAttention(
(dropout): Dropout(p=0.1, inplace=False)
(sampling_offsets): Linear(in_features=256, out_features=256, bias=True)
(attention_weights): Linear(in_features=256, out_features=128, bias=True)
(value_proj): Linear(in_features=256, out_features=256, bias=True)
(output_proj): Linear(in_features=256, out_features=256, bias=True)
)
)
(ffns): ModuleList(
(0): FFN(
(activate): ReLU(inplace=True)
(layers): Sequential(
(0): Sequential(
(0): Linear(in_features=256, out_features=1024, bias=True)
(1): ReLU(inplace=True)
(2): Dropout(p=0.1, inplace=False)
)
(1): Linear(in_features=1024, out_features=256, bias=True)
(2): Dropout(p=0.1, inplace=False)
)
(dropout_layer): Identity()
)
)
(norms): ModuleList(
(0): LayerNorm((256,), eps=1e-05, elementwise_affine=True)
(1): LayerNorm((256,), eps=1e-05, elementwise_affine=True)
(2): LayerNorm((256,), eps=1e-05, elementwise_affine=True)
)
)

  • 先经过一个普通的多头注意力机制,然后经过multi-scaleDeformerbleAttention,然后和之前encoder差不多的ffn和LN,一些常见层的叠加,没有心意,不做赘述。得到最终的结果,这里作者把刘哥block得到的结果都返回了(6,300,1,256)
  • 之后对每一个block得到的结果进行处理得到每个block的结果
  • cls_branches区别具体类别
    在这里插入图片描述
  • reg_branches根据前面得到的结果得到box,由6个block组成
    在这里插入图片描述
  • 6层,每一层都会得到class和box 【注:这个结果是DETRhead应该得到的结果】
    class
    在这里插入图片描述
  • 将输出和label组装好去计算loss咯,6层最后针对每一层都会输出相应的class_loss,box_loss和iou_loss
    在这里插入图片描述
  • 输出每一层的loss以及所有loss的加和,但是最关键的还是最后一层的loss
  • 到这里一个完整的train过程就结束啦,但是为了加深理解,我想在后面部分记录loss的计算过程

7. loss_single

  • 首先进行正样本选择get_targets

    关于get_target
    输入
    cls_scores_list (list[Tensor]): Box score logits from a single decoder layer for each image with shape [num_query,cls_out_channels].
    bbox_preds_list (list[Tensor]): Sigmoid outputs from a single decoder layer for each image, with normalized coordinate (cx, cy, w, h) and shape [num_query, 4].
    gt_bboxes_list (list[Tensor]): Ground truth bboxes for each image with shape (num_gts, 4) in [tl_x, tl_y, br_x, br_y] format.
    gt_labels_list (list[Tensor]): Ground truth class indices for each image with shape (num_gts, ).
    img_metas (list[dict]): List of image meta information.
    gt_bboxes_ignore_list (list[Tensor], optional): Bounding boxes which can be ignored for each image. Default None.
    输出 tuple: a tuple containing the following targets
    labels_list (list[Tensor]): Labels for all images.
    label_weights_list (list[Tensor]): Label weights for all images.
    bbox_targets_list (list[Tensor]): BBox targets for all images.
    bbox_weights_list (list[Tensor]): BBox weights for all images.
    num_total_pos (int): Number of positive samples in all images.
    num_total_neg (int): Number of negative samples in all images.

  • get_targets中的重要function是get_target_single——Compute regression and classification targets for one image.

  • get_target_single中先得到assign,pred和groundtruth之间匹配

  • 需要先计算class和box等误差,class 的loss使用focal loss,还有box的回归loss 以及box的giou 作为第三个loss

  • 将三个loss加权后相加得到cost【object_num* groundtruth_num】

  • 对这个cost做匈牙利匹配找到300个object anchor 中与groundtruth最匹配的anchor【这里的匈牙利匹配实现使用linear_sum_assignment,返回与之匹配的row_index和col_index】

  • 根据assign得到的结果去采样得到postive index和negative index

  • 根据匹配结果得到300个object anchor的label,label的weight,box的列表和label

  • 根据上述得到的结果做class_loss,reg_loss和giou_loss

我今天一天终于全部搞明白了,好开心,虽然很慢,但是收获很多,算是每一步骤都懂了!RESPECT!!!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/782410.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

Linux:多进程和多线程回环socket服务器和客户端

多进程socket服务器代码&#xff1a; #include <stdio.h> #include <unistd.h> #include <sys/types.h> #include <sys/socket.h> #include <arpa/inet.h> #include <string.h> #include <ctype.h> #include <sys/wait.h> #i…

JWT 使用

前端访问后台a系统和b系统访问 Json web token (JWT), 是为了在网络应用环境间传递声明而执行的一种基于JSON的开放标准&#xff08;(RFC 7519).该token被设计为紧凑且安全的&#xff0c;特别适用于分布式站点的单点登录&#xff08;SSO&#xff09;场景。 JWT的本质就是一个…

记录安装DragGAN遇到的问题

首先第一个是安装的问题 安装的envirenment.yml有很多包过时了下载不了&#xff0c;可以参考以下文章写一个requirement.txt来下载依赖环境 --extra-index-url https://download.pytorch.org/whl/cu118 numpy1.23.5 click scipy pillow9.5.0 requests tqdm4.65.0 ninja matpl…

哪些语句会被waf屏蔽?

什么是waf&#xff1a;Web应用防火墙&#xff0c;Web Application Firewall的简称。 waf的功能&#xff1a;WAF可以发现和拦截各类Web层面的攻击&#xff0c;记录攻击日志&#xff0c;实时预警提醒&#xff0c;在Web应 用本身存在缺陷的情况下保障其安全。 封IP &#xff1a;…

Qt应用开发——QLineEdit

目录 一、概述 二、属性和方法 三、信号 一、概述 QLineEdit允许用户输入和编辑单行纯文本&#xff0c;并可以使用快捷编辑功能&#xff0c;包括复制、粘贴、剪切和拖放。是项目开发中最常用的输入控件。 默认键绑定描述如下。 Left Arrow //将光标向左移…

Fourier变换极其应用(Brad G. Osgood)——第1章——Fourier级数

目录 第1章 Fourier级数 1.1 选择&#xff1a;“欢迎入局”(Choices: Welcome Aboard) 1.2 周期性现象(Periodic phenomena) 1.2.1 时间和空间(time and space) 1.2.1.1 时间和空间周期性在波动中最自然地结合在一起 1.2.1.2 更多关于空间的周期性例子 1.2.2 定义&…

11 简单的Thymeleaf语法

11.1 spring-boot环境准备 重要依赖&#xff1a; <!--thymeleaf--> <dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-thymeleaf</artifactId> </dependency> 11.2 转发消息不转义 就是如…

picgo Request failed with status code 404

今天写picgo的时候&#xff0c;出现了一个错误&#xff0c;如何解决&#xff1a; 这里是repo的配置出现了问题&#xff0c;不过我的是因为粗心&#xff0c;把master写成了mater&#xff0c;emmmm 这里的repo要跟仓库的地址相同就是这一块&#xff1a;把这一块填到repo就行 然…

Linux查看二进制文件

Linux查看二进制文件 hexdump、hd、od、xxd hexdump、hd 可以使用16进制、10进制、8进制、ascii码的形式查看文件。 执行 ls -al which hd就会看到hd其实只是hexdump的一个软链接。 使用man hexdump&#xff0c;可以查看hexdump的各种参数。 -b, --one-byte-octal 单字节…

使用SQL JOIN语句把来自两个或多个表的行结合起来

先创建一个表&#xff1a; 创建一个名为 websites 的表 CREATE TABLE websites ( id int, name varchar(255), url varchar(255), alexa varchar(255), country varchar(255) ); 然后给它插入一些数据&#xff08;插入了四行新数据&#xff09;&#xff1a; insert into we…

详解go的hex.Encode原理

简言 今天看nsq的messageID生成的时候&#xff0c;发现它使用了hex.Encode函数来产生编码&#xff0c;那就顺道研究一下这个编码方式。 原理 hex是16进制的意思&#xff0c;encode是进行编码的意思&#xff0c;内部实现也很简单&#xff0c;就是 每4位计算出十六进制的值&a…

Idea项目初始化配置

Idea项目初始化配置 &#x1f4d4; 千寻简笔记介绍 千寻简笔记已开源&#xff0c;Gitee与GitHub搜索chihiro-notes&#xff0c;包含笔记源文件.md&#xff0c;以及PDF版本方便阅读&#xff0c;且是用了精美主题&#xff0c;阅读体验更佳&#xff0c;如果文章对你有帮助请帮我…

Node.js: express + MySQL实现修改密码

实现修改密码&#xff0c;本篇文章实现修改密码只考虑以下几个方面&#xff1a; &#xff08;1&#xff09;&#xff0c;获取旧密码 &#xff08;2&#xff09;&#xff0c;获取新密码 &#xff08;3&#xff09;&#xff0c;将获取到的旧密码与数据库中的密码进行比对&#xf…

IC 后端 corner 介绍

在数字IC后端&#xff0c;有对晶体管的偏差建模的PVT corner&#xff0c;以及对互连线偏差建模的RC corner。 芯片的延迟一般受到三个因素的影响&#xff1a;工艺&#xff08;Process&#xff09;、电压&#xff08;Voltage&#xff09;、温度&#xff08;Temperature&#xff…

rabbitmq是什么?rabbitmq安装、原理、部署

rabbitmq是什么&#xff1f; MQ的全称是Messagee Queue&#xff0c;因为消息的队列是队列&#xff0c;所以遵循FIFO 先进先出的原则是上下游传递信息的跨过程通信机制。 RabbitMQ是一套开源&#xff08;MPL&#xff09;新闻队列服务软件由 LShift 提供的一个 Advanced Messag…

linux学成之路(基础篇)(二十一)nfs服务器

前言 NFS是Network File System的缩写&#xff0c;它是一种在计算机网络中共享文件和文件系统的协议。NFS允许不同的计算机系统之间通过网络访问、读取和写入远程文件&#xff0c;就像访问本地文件一样。它是一种基于客户端-服务器体系结构的协议&#xff0c;其中一个计算机充当…

Python(三十五)pass语句

❤️ 专栏简介&#xff1a;本专栏记录了我个人从零开始学习Python编程的过程。在这个专栏中&#xff0c;我将分享我在学习Python的过程中的学习笔记、学习路线以及各个知识点。 ☀️ 专栏适用人群 &#xff1a;本专栏适用于希望学习Python编程的初学者和有一定编程基础的人。无…

excel中的vlookup如何实现根据多个条件查找?

目录 简述问题公式思路通用公式三条件查找公式实例 简述 Excel 中根据一个条件查找非常方便&#xff0c;Excel 提供了内置函数 VLOOKUP。但是实际中往往有多种情形&#xff0c;需要根据多个条件进行查找操作&#xff0c;目前没有现成的内置函数。 本篇介绍 VLOOKPCHOOSE 组合…

SpringBoot读取配置的几种方式

SpringBoot读取配置的方式有多种&#xff0c;这里介绍6种 1.第一种Value 注意&#xff1a;static和final修饰的变量不生效 2.通过ConfigurationProperties&#xff08;prefix“”&#xff09; 适用于对对象多个变量统一绑定&#xff0c;比Value高效 3.通过Environment Sprin…

信创环境下,使用国产服务器如何进行文件高速可靠传输?

信创&#xff0c;即信息技术应用创新&#xff0c;2018年以来&#xff0c;受“华为、中兴事件”影响&#xff0c;国家将信创产业纳入国家战略&#xff0c;并提出了“28n”发展体系。从产业链角度&#xff0c;信创产业生态体系较为庞大&#xff0c;主要包括基础硬件、基础软件、应…