【五一创作】Pytroch nn.Unfold() 与 nn.Fold()图码详解

这篇具有很好参考价值的文章主要介绍了【五一创作】Pytroch nn.Unfold() 与 nn.Fold()图码详解。希望对大家有所帮助。如果存在错误或未考虑完全的地方,请大家不吝赐教,您也可以点击"举报违法"按钮提交疑问。

Unfold()与Fold()的用途

Unfold()Fold()一般成对出现。常用用途有:

  1. 代替卷积计算,Unfold()Fold()不互逆(参数不一样)(卷积本来就不可逆)
  2. 图片patch化,Unfold()Fold()互逆(参数一样,且滑动窗不重叠)

nn.Unfold()

Extracts sliding local blocks from a batched input tensor.
在各滑动窗中按行展开(行向量化),然后转置成列向量, im2col 的批量形式

input : (N, C, ∗)
output : (N, C × ∏(kernel_size), L)

# 滑动窗口有重叠
unfold = nn.Unfold(kernel_size=(2, 3))
input = torch.randn(2, 5, 3, 4)
print("input: \n", input)
output = unfold(input)
# each patch contains 30 values (2x3=6 vectors, each of 5 channels)
# 4 blocks (2x3 kernels) in total in the 3x4 input
# output.size()  # torch.Size([2, 30, 4])
print("output: \n", output)

fold = nn.Fold((3,4),(2,3))
fold_output = fold(output)
print("fold_output: \n", fold_output)

输出为:

input: 
 tensor([[[[ 0.4198,  1.0535,  0.1152,  0.3510],
          [ 1.1664,  0.3376,  1.2207,  0.3575],
          [-0.2174, -1.2490,  0.3432,  0.3388]],

         [[-1.4956,  0.9746, -0.5145,  0.1722],
          [ 1.7041,  0.9645, -0.6937, -1.9037],
          [-0.1961, -0.3345,  0.3565, -1.2329]],

         [[-0.9843, -0.8089,  1.8712, -0.2860],
          [ 0.0960, -1.7501, -0.1226,  0.9383],
          [-0.1675,  1.1498, -0.4958, -1.2953]],

         [[-1.2368,  0.5667,  1.4166, -2.2567],
          [ 0.9414,  0.8189,  1.5604,  0.1422],
          [-1.6414, -1.5594,  0.6718,  1.2319]],

         [[-0.4093,  0.6691,  1.4003,  0.7444],
          [-0.2858, -0.4375, -1.1301,  0.7377],
          [-0.0956, -0.1844,  0.7697, -0.3077]]],


        [[[ 0.4264, -0.0700, -1.5600, -0.0491],
          [ 1.5027,  3.1625,  0.6080, -1.8794],
          [-0.3148,  0.6377, -0.7242,  0.1692]],

         [[ 0.2757, -0.5403,  0.7748, -1.1795],
          [ 0.1504, -0.4671,  0.9355,  1.3050],
          [-0.4920, -0.8581,  0.0559, -0.0446]],

         [[ 2.1627,  0.6758, -0.0968,  1.3401],
          [-0.1105,  0.8299, -0.3827, -1.0687],
          [-0.2234, -1.0423,  1.2436, -0.6514]],

         [[ 0.8085, -0.4159,  0.2022,  0.5747],
          [-0.1265,  0.2828, -1.3530,  0.2831],
          [-0.1571,  0.9005,  0.4556, -1.4360]],

         [[-1.2417,  0.1829,  0.3825, -0.8555],
          [-2.0170,  0.7537,  2.3406,  0.5866],
          [-1.1704, -1.8986, -0.7958,  0.2652]]]])
output: 
 tensor([[[ 0.4198,  1.0535,  1.1664,  0.3376],
         [ 1.0535,  0.1152,  0.3376,  1.2207],
         [ 0.1152,  0.3510,  1.2207,  0.3575],
         [ 1.1664,  0.3376, -0.2174, -1.2490],
         [ 0.3376,  1.2207, -1.2490,  0.3432],
         [ 1.2207,  0.3575,  0.3432,  0.3388],
         [-1.4956,  0.9746,  1.7041,  0.9645],
         [ 0.9746, -0.5145,  0.9645, -0.6937],
         [-0.5145,  0.1722, -0.6937, -1.9037],
         [ 1.7041,  0.9645, -0.1961, -0.3345],
         [ 0.9645, -0.6937, -0.3345,  0.3565],
         [-0.6937, -1.9037,  0.3565, -1.2329],
         [-0.9843, -0.8089,  0.0960, -1.7501],
         [-0.8089,  1.8712, -1.7501, -0.1226],
         [ 1.8712, -0.2860, -0.1226,  0.9383],
         [ 0.0960, -1.7501, -0.1675,  1.1498],
         [-1.7501, -0.1226,  1.1498, -0.4958],
         [-0.1226,  0.9383, -0.4958, -1.2953],
         [-1.2368,  0.5667,  0.9414,  0.8189],
         [ 0.5667,  1.4166,  0.8189,  1.5604],
         [ 1.4166, -2.2567,  1.5604,  0.1422],
         [ 0.9414,  0.8189, -1.6414, -1.5594],
         [ 0.8189,  1.5604, -1.5594,  0.6718],
         [ 1.5604,  0.1422,  0.6718,  1.2319],
         [-0.4093,  0.6691, -0.2858, -0.4375],
         [ 0.6691,  1.4003, -0.4375, -1.1301],
         [ 1.4003,  0.7444, -1.1301,  0.7377],
         [-0.2858, -0.4375, -0.0956, -0.1844],
         [-0.4375, -1.1301, -0.1844,  0.7697],
         [-1.1301,  0.7377,  0.7697, -0.3077]],

        [[ 0.4264, -0.0700,  1.5027,  3.1625],
         [-0.0700, -1.5600,  3.1625,  0.6080],
         [-1.5600, -0.0491,  0.6080, -1.8794],
         [ 1.5027,  3.1625, -0.3148,  0.6377],
         [ 3.1625,  0.6080,  0.6377, -0.7242],
         [ 0.6080, -1.8794, -0.7242,  0.1692],
         [ 0.2757, -0.5403,  0.1504, -0.4671],
         [-0.5403,  0.7748, -0.4671,  0.9355],
         [ 0.7748, -1.1795,  0.9355,  1.3050],
         [ 0.1504, -0.4671, -0.4920, -0.8581],
         [-0.4671,  0.9355, -0.8581,  0.0559],
         [ 0.9355,  1.3050,  0.0559, -0.0446],
         [ 2.1627,  0.6758, -0.1105,  0.8299],
         [ 0.6758, -0.0968,  0.8299, -0.3827],
         [-0.0968,  1.3401, -0.3827, -1.0687],
         [-0.1105,  0.8299, -0.2234, -1.0423],
         [ 0.8299, -0.3827, -1.0423,  1.2436],
         [-0.3827, -1.0687,  1.2436, -0.6514],
         [ 0.8085, -0.4159, -0.1265,  0.2828],
         [-0.4159,  0.2022,  0.2828, -1.3530],
         [ 0.2022,  0.5747, -1.3530,  0.2831],
         [-0.1265,  0.2828, -0.1571,  0.9005],
         [ 0.2828, -1.3530,  0.9005,  0.4556],
         [-1.3530,  0.2831,  0.4556, -1.4360],
         [-1.2417,  0.1829, -2.0170,  0.7537],
         [ 0.1829,  0.3825,  0.7537,  2.3406],
         [ 0.3825, -0.8555,  2.3406,  0.5866],
         [-2.0170,  0.7537, -1.1704, -1.8986],
         [ 0.7537,  2.3406, -1.8986, -0.7958],
         [ 2.3406,  0.5866, -0.7958,  0.2652]]])
fold_output: 
 tensor([[[[ 0.4198,  2.1070,  0.2304,  0.3510],
          [ 2.3328,  1.3502,  4.8828,  0.7150],
          [-0.2174, -2.4979,  0.6865,  0.3388]],

         [[-1.4956,  1.9493, -1.0290,  0.1722],
          [ 3.4083,  3.8582, -2.7747, -3.8074],
          [-0.1961, -0.6690,  0.7129, -1.2329]],

         [[-0.9843, -1.6178,  3.7424, -0.2860],
          [ 0.1920, -7.0003, -0.4904,  1.8766],
          [-0.1675,  2.2995, -0.9917, -1.2953]],

         [[-1.2368,  1.1334,  2.8331, -2.2567],
          [ 1.8829,  3.2758,  6.2418,  0.2843],
          [-1.6414, -3.1189,  1.3435,  1.2319]],

         [[-0.4093,  1.3382,  2.8006,  0.7444],
          [-0.5717, -1.7500, -4.5204,  1.4754],
          [-0.0956, -0.3688,  1.5395, -0.3077]]],


        [[[ 0.4264, -0.1399, -3.1201, -0.0491],
          [ 3.0053, 12.6500,  2.4319, -3.7589],
          [-0.3148,  1.2753, -1.4484,  0.1692]],

         [[ 0.2757, -1.0806,  1.5497, -1.1795],
          [ 0.3007, -1.8684,  3.7421,  2.6100],
          [-0.4920, -1.7162,  0.1119, -0.0446]],

         [[ 2.1627,  1.3515, -0.1936,  1.3401],
          [-0.2210,  3.3198, -1.5307, -2.1373],
          [-0.2234, -2.0846,  2.4872, -0.6514]],

         [[ 0.8085, -0.8318,  0.4044,  0.5747],
          [-0.2529,  1.1310, -5.4121,  0.5662],
          [-0.1571,  1.8010,  0.9112, -1.4360]],

         [[-1.2417,  0.3659,  0.7650, -0.8555],
          [-4.0339,  3.0146,  9.3626,  1.1733],
          [-1.1704, -3.7972, -1.5917,  0.2652]]]])

Unfold()与Fold() 变化模式图解

以上面代码输出为例,其实是以如下的格式对原数据进行组织排列的:
在各滑动窗中按行展开(行向量化),然后转置成列向量, 是im2col的批量形式。
【五一创作】Pytroch nn.Unfold() 与 nn.Fold()图码详解
【五一创作】Pytroch nn.Unfold() 与 nn.Fold()图码详解
然后,对Unfold()的结果以相同参数运用Fold()后(Fold()的讲解在下面,这里先给出结果),结果如下:
【五一创作】Pytroch nn.Unfold() 与 nn.Fold()图码详解

nn.Fold()

nn.Fold() 是 nn.Unfold() 函数的逆操作。 (参数相同、滑动窗口没有重叠的情况下,可以完全恢复【真互逆】。滑动窗口有重叠情况下不能恢复到Unfold的输入)

需要注意的是,如果滑动窗口有重叠,那么重叠部分相加【倍数关系】。同时,如果原来的图像不够划分的话就会舍去。在恢复时就会以 0 填充

单通道 滑动窗口无重叠

# 单通道  滑动窗口无重叠
import torch.nn as nn
import torch
 
batches_img = torch.rand(1,1,6,6)
print("batches_img: ",batches_img)
 
unfold = nn.Unfold(kernel_size=(3,3),stride=3)
patche_img = unfold(batches_img)
print("patche_img.shape: ",patche_img.shape)
print(patche_img)
 
fold = torch.nn.Fold(output_size=(6, 6), kernel_size=(3, 3), stride=3)
inputs_restore = fold(patche_img)
print("inputs_restore:", inputs_restore)

输出:

batches_img:  tensor([[[[0.0174, 0.3919, 0.0073, 0.4660, 0.6537, 0.0584],
          [0.9763, 0.9982, 0.6250, 0.1332, 0.2123, 0.9500],
          [0.5482, 0.4291, 0.9430, 0.6837, 0.6975, 0.1992],
          [0.5275, 0.6800, 0.0490, 0.0350, 0.8571, 0.2449],
          [0.3719, 0.7484, 0.7677, 0.4164, 0.2151, 0.8875],
          [0.0784, 0.3839, 0.7567, 0.4217, 0.3208, 0.3025]]]])
patche_img.shape:  torch.Size([1, 9, 4])
tensor([[[0.0174, 0.4660, 0.5275, 0.0350],
         [0.3919, 0.6537, 0.6800, 0.8571],
         [0.0073, 0.0584, 0.0490, 0.2449],
         [0.9763, 0.1332, 0.3719, 0.4164],
         [0.9982, 0.2123, 0.7484, 0.2151],
         [0.6250, 0.9500, 0.7677, 0.8875],
         [0.5482, 0.6837, 0.0784, 0.4217],
         [0.4291, 0.6975, 0.3839, 0.3208],
         [0.9430, 0.1992, 0.7567, 0.3025]]])
inputs_restore: tensor([[[[0.0174, 0.3919, 0.0073, 0.4660, 0.6537, 0.0584],
          [0.9763, 0.9982, 0.6250, 0.1332, 0.2123, 0.9500],
          [0.5482, 0.4291, 0.9430, 0.6837, 0.6975, 0.1992],
          [0.5275, 0.6800, 0.0490, 0.0350, 0.8571, 0.2449],
          [0.3719, 0.7484, 0.7677, 0.4164, 0.2151, 0.8875],
          [0.0784, 0.3839, 0.7567, 0.4217, 0.3208, 0.3025]]]])

模拟图片数据(b,3,9,9),通道数 C 为3,滑动窗口无重叠。

相较于上面的代码,变化仅此

# 模拟图片数据(b,3,9,9),通道数 C 为3,滑动窗口无重叠。 相较于上面的代码,变化仅此
import torch.nn as nn
import torch
 
batches_img = torch.rand(1,3,6,6)
print("batches_img: ",batches_img)
 
unfold = nn.Unfold(kernel_size=(3,3),stride=3)
patche_img = unfold(batches_img)
print("patche_img.shape: ",patche_img.shape)
print(patche_img)
 
fold = torch.nn.Fold(output_size=(6, 6), kernel_size=(3, 3), stride=3)
inputs_restore = fold(patche_img)
print("inputs_restore:", inputs_restore)

输出为:

batches_img:  tensor([[[[0.6072, 0.9496, 0.4149, 0.1085, 0.6808, 0.3949],
          [0.9770, 0.4831, 0.3964, 0.6597, 0.1749, 0.7326],
          [0.4379, 0.0159, 0.2946, 0.4129, 0.1445, 0.5479],
          [0.1664, 0.6725, 0.5104, 0.4171, 0.6656, 0.3146],
          [0.5126, 0.2331, 0.8167, 0.2695, 0.6420, 0.8591],
          [0.2282, 0.6300, 0.9205, 0.6741, 0.6085, 0.7866]],

         [[0.7943, 0.8348, 0.5379, 0.1951, 0.2629, 0.7281],
          [0.5726, 0.4912, 0.5636, 0.7816, 0.9746, 0.3764],
          [0.5440, 0.3434, 0.5914, 0.5925, 0.9556, 0.0455],
          [0.0810, 0.0730, 0.2580, 0.0785, 0.2483, 0.3810],
          [0.4182, 0.7024, 0.4904, 0.6935, 0.1789, 0.1015],
          [0.2571, 0.9138, 0.1987, 0.6266, 0.0760, 0.4618]],

         [[0.3554, 0.2476, 0.3415, 0.5014, 0.1018, 0.3563],
          [0.2180, 0.5690, 0.9975, 0.8152, 0.5812, 0.2704],
          [0.5717, 0.9419, 0.4398, 0.5708, 0.2666, 0.3507],
          [0.3868, 0.6889, 0.0326, 0.7873, 0.7444, 0.8057],
          [0.1440, 0.9667, 0.2522, 0.9718, 0.6078, 0.2911],
          [0.1442, 0.3061, 0.4116, 0.4190, 0.2343, 0.2608]]]])
patche_img.shape:  torch.Size([1, 27, 4])
tensor([[[0.6072, 0.1085, 0.1664, 0.4171],
         [0.9496, 0.6808, 0.6725, 0.6656],
         [0.4149, 0.3949, 0.5104, 0.3146],
         [0.9770, 0.6597, 0.5126, 0.2695],
         [0.4831, 0.1749, 0.2331, 0.6420],
         [0.3964, 0.7326, 0.8167, 0.8591],
         [0.4379, 0.4129, 0.2282, 0.6741],
         [0.0159, 0.1445, 0.6300, 0.6085],
         [0.2946, 0.5479, 0.9205, 0.7866],
         [0.7943, 0.1951, 0.0810, 0.0785],
         [0.8348, 0.2629, 0.0730, 0.2483],
         [0.5379, 0.7281, 0.2580, 0.3810],
         [0.5726, 0.7816, 0.4182, 0.6935],
         [0.4912, 0.9746, 0.7024, 0.1789],
         [0.5636, 0.3764, 0.4904, 0.1015],
         [0.5440, 0.5925, 0.2571, 0.6266],
         [0.3434, 0.9556, 0.9138, 0.0760],
         [0.5914, 0.0455, 0.1987, 0.4618],
         [0.3554, 0.5014, 0.3868, 0.7873],
         [0.2476, 0.1018, 0.6889, 0.7444],
         [0.3415, 0.3563, 0.0326, 0.8057],
         [0.2180, 0.8152, 0.1440, 0.9718],
         [0.5690, 0.5812, 0.9667, 0.6078],
         [0.9975, 0.2704, 0.2522, 0.2911],
         [0.5717, 0.5708, 0.1442, 0.4190],
         [0.9419, 0.2666, 0.3061, 0.2343],
         [0.4398, 0.3507, 0.4116, 0.2608]]])
inputs_restore: tensor([[[[0.6072, 0.9496, 0.4149, 0.1085, 0.6808, 0.3949],
          [0.9770, 0.4831, 0.3964, 0.6597, 0.1749, 0.7326],
          [0.4379, 0.0159, 0.2946, 0.4129, 0.1445, 0.5479],
          [0.1664, 0.6725, 0.5104, 0.4171, 0.6656, 0.3146],
          [0.5126, 0.2331, 0.8167, 0.2695, 0.6420, 0.8591],
          [0.2282, 0.6300, 0.9205, 0.6741, 0.6085, 0.7866]],

         [[0.7943, 0.8348, 0.5379, 0.1951, 0.2629, 0.7281],
          [0.5726, 0.4912, 0.5636, 0.7816, 0.9746, 0.3764],
          [0.5440, 0.3434, 0.5914, 0.5925, 0.9556, 0.0455],
          [0.0810, 0.0730, 0.2580, 0.0785, 0.2483, 0.3810],
          [0.4182, 0.7024, 0.4904, 0.6935, 0.1789, 0.1015],
          [0.2571, 0.9138, 0.1987, 0.6266, 0.0760, 0.4618]],

         [[0.3554, 0.2476, 0.3415, 0.5014, 0.1018, 0.3563],
          [0.2180, 0.5690, 0.9975, 0.8152, 0.5812, 0.2704],
          [0.5717, 0.9419, 0.4398, 0.5708, 0.2666, 0.3507],
          [0.3868, 0.6889, 0.0326, 0.7873, 0.7444, 0.8057],
          [0.1440, 0.9667, 0.2522, 0.9718, 0.6078, 0.2911],
          [0.1442, 0.3061, 0.4116, 0.4190, 0.2343, 0.2608]]]])

单通道 滑动窗口有重叠。

kernel_size=(3,3),stride=2

# 单通道 滑动窗口有重叠。  kernel_size=(3,3),stride=2
import torch.nn as nn
import torch
 
batches_img = torch.rand(1,1,6,6)
print("batches_img: \n",batches_img)
 
unfold = nn.Unfold(kernel_size=(3,3),stride=2)
patche_img = unfold(batches_img)
print("patche_img.shape: ",patche_img.shape)
print(patche_img)
 
fold = torch.nn.Fold(output_size=(6, 6), kernel_size=(3, 3), stride=2)
inputs_restore = fold(patche_img)
print("inputs_restore: \n", inputs_restore)

输出为:

batches_img: 
 tensor([[[[0.4171, 0.0129, 0.2183, 0.0610, 0.5242, 0.9530],
          [0.7112, 0.7892, 0.2548, 0.4604, 0.7200, 0.0294],
          [0.0754, 0.0451, 0.2892, 0.6765, 0.8671, 0.5574],
          [0.4220, 0.4499, 0.8946, 0.0149, 0.6790, 0.0719],
          [0.1529, 0.2815, 0.8502, 0.5781, 0.0339, 0.9916],
          [0.6900, 0.4843, 0.3190, 0.0676, 0.8558, 0.0060]]]])
patche_img.shape:  torch.Size([1, 9, 4])
tensor([[[0.4171, 0.2183, 0.0754, 0.2892],
         [0.0129, 0.0610, 0.0451, 0.6765],
         [0.2183, 0.5242, 0.2892, 0.8671],
         [0.7112, 0.2548, 0.4220, 0.8946],
         [0.7892, 0.4604, 0.4499, 0.0149],
         [0.2548, 0.7200, 0.8946, 0.6790],
         [0.0754, 0.2892, 0.1529, 0.8502],
         [0.0451, 0.6765, 0.2815, 0.5781],
         [0.2892, 0.8671, 0.8502, 0.0339]]])
inputs_restore: 
 tensor([[[[0.4171, 0.0129, 0.4365, 0.0610, 0.5242, 0.0000],
          [0.7112, 0.7892, 0.5095, 0.4604, 0.7200, 0.0000],
          [0.1507, 0.0902, 1.1567, 1.3530, 1.7342, 0.0000],
          [0.4220, 0.4499, 1.7892, 0.0149, 0.6790, 0.0000],
          [0.1529, 0.2815, 1.7005, 0.5781, 0.0339, 0.0000],
          [0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000]]]])
# 重复累加次数最多的元素:
batches_img[0,0,2,2]*4  
# 输出:tensor(1.1567)

卷积等价于:Unfold + Matrix Multiplication + Fold (或view()到卷积输出形状)

注: 使用 Unfold + Matrix Multiplication + Fold 来代替卷积时,Fold 中的 kernel size 需要为 (1,1)文章来源地址https://www.toymoban.com/news/detail-431600.html

inp = torch.randn(1, 3, 10, 12)
w = torch.randn(2, 3, 4, 5)
inp_unf = torch.nn.functional.unfold(inp, (4, 5))
out_unf = inp_unf.transpose(1, 2).matmul(w.view(w.size(0), -1).t()).transpose(1, 2)  # 下面自己实现的更简洁
out = torch.nn.functional.fold(out_unf, (7, 8), (1, 1))
# or equivalently (and avoiding a copy),
# out = out_unf.view(1, 2, 7, 8)
print((torch.nn.functional.conv2d(inp, w) - out).abs().max())  # tensor(1.9073e-06)

out_unf_jason = w.view(w.size(0), -1).matmul(inp_unf)
out_jason = out_unf_jason.view(1, 2, 7, 8)
print((torch.nn.functional.conv2d(inp, w) - out_jason).abs().max())  # tensor(1.9073e-06)

到了这里,关于【五一创作】Pytroch nn.Unfold() 与 nn.Fold()图码详解的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请点击违法举报进行投诉反馈,一经查实,立即删除!

领支付宝红包 赞助服务器费用

相关文章

  • 【五一创作】VimPlug插件配置

    目录 Install Question Q1:字体乱码 Q2:插件配置 Q3:安装扩展插件 Q4:查看安装插件状态 Q5:查看默认插件 Q6:卸载插件 Q7:增加用户配置 Github地址:GitHub - chxuan/vimplus: An automatic configuration program for vim Q1:字体乱码 打开终端,右键,配置文件首选项,配置,字体栏目选择 Dro

    2024年02月02日
    浏览(81)
  • 【五一创作】红黑树数据结构

    现在JAVASE中HashMap中底层源码是由数组+链表+红黑树进行设计的,然后很多地方也是用到红黑树,这里单独对红黑树数据结构进行简单的介绍。 目录 红黑树概念 红黑树的性质 自平衡规则 代码   红黑树,是一种二叉搜索树,但在每个结点上增加一个存储位表示结点的颜色,可

    2024年02月05日
    浏览(57)
  • 【五一创作】|【C++】AVL树的实现

    二叉搜索树虽可以缩短查找的效率,但如果数据有序或接近有序二叉搜索树将退化为单支树,查 找元素相当于在顺序表中搜索元素,效率低下, 所以在此基础上提出解决办法: 当向二叉搜索树中插入新节结点时,如果能保证每个节点的左右子树高度之差的绝对值不超过1即可

    2024年02月04日
    浏览(43)
  • 【五一创作】Python项目怎么部署到spring

    首先,需要确保Python项目已经编写完成并且可运行。然后,可以使用以下步骤将Python项目部署到Spring中: 1. 安装Jython:Jython是一个Java平台上的Python解释器。在Spring中使用Jython可以使Python代码能够与Java代码无缝集成。可以从Jython官方网站下载并安装Jython。 2. 将Python代码转换为

    2024年02月04日
    浏览(40)
  • 【五一创作】自动驾驶技术未来大有可为

    自动驾驶技术是当今汽车行业的发展热点之一,但其也存在着许多争议。大家也可以从以下几个维度谈谈你对这项技术的看法。 ☀️大家好!我是新人小白博主朦胧的雨梦,希望大家多多关照和支持😝😝😝 🌖大家一起努力,共同成长,相信我们都会遇到更好的自己👊👊👊

    2024年02月04日
    浏览(39)
  • 【五一创作】MysqlFirst项目过程中遇到的困难

    解决办法:实体类字段属性不要使用基本数据类型(比如int ,long等),要使用Long,Integer等包装类 修改后就没报此错误了。 解决方法:使用input中的type为hidden 写到点击菜系跳转servlet这里 如何做批处理 [外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传

    2024年02月02日
    浏览(36)
  • 【五一创作】基于springboot框架的电脑商城项目(三)

    1.规划sql 根据用户id修改信息的SQL语句 根据用户id查询的sql语句 2.接口与抽象方法 更新用户的信息方法的定义 在UserMapper.xml文件中进行映射编写 设计两个功能: 1.当打开页面时显示当前登录的用户的信息 2.点击修改按钮时更新用户的信息 1.异常规划 点击个人资料页面时可能找

    2024年02月04日
    浏览(53)
  • 【五一创作】VUE基础知识——代理服务器

    目录 前言 代理方式一 优点 缺点 工作方式 代理方式二 优点 缺点 今天为什么要讲这个vue脚手架的代理呢? 接下来我们先来聊一下cros,相信大家对于这个单词都不会陌生吧!当我们前端请求发生了错误提示这个词的时候,那么基本上就是跨域了。如何解决跨域其实有多种。

    2024年02月02日
    浏览(71)
  • 【五一创作】Visual Studio常用调试技巧的温习

    当你在编写C程序时,难免会遇到代码出现错误的情况。这时候就需要用调试工具来定位问题并解决它。以下是一些在Visual Studio中使用调试器时常用的技巧,权当作温故总结罢~ 1. 断点 断点是调试中最为基本但也最常用的技巧之一。通过在需要定位的代码行上打上断点,程序

    2024年02月04日
    浏览(52)
  • 【五一创作】某头条参数破解并实现界面化搭建

    趁着日常闲余时间,想着搞一搞某条的反爬,练练手,想到自己很久没开发过前端界面了,有点生疏,也趁此机会用flask开发一个简单的搜索界面(真的很简单…) 首页会展示实时热点信息 搜索界面中会根据输入的内容进行搜索,展示搜索结果第一页 热点接口链接 aHR0cHM6L

    2024年02月01日
    浏览(36)

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

请作者喝杯咖啡吧~博客赞助

支付宝扫一扫领取红包,优惠每天领

二维码1

领取红包

二维码2

领红包