zoukankan      html  css  js  c++  java
  • pytorch中的ReflectionPad2d

    torch.nnReflectionPad2d

    一、原理

    增加边界的类型有以下4个类型:以一行图像数据为例,abcdefgh是原图数据,|是图像边界,为原图加边

    1 aaaaaa|abcdefgh|hhhhhhh 重复
    2 fedcba|abcdefgh|hgfedcb 反射
    3 gfedcb|abcdefgh|gfedcba 反射101,相当于上一行的左右互换
    4 cdefgh|abcdefgh|abcdefg 外包装
    5 iiiiii|abcdefgh|iiiiiii with some specified 'i' 常量
    

    torch.nn.ReflectionPad2d(padding) 使用输入边界的反射填充输入张量。填充长度为 padding。当以元组的方式传入参数的时候,四元组代表left ,right,top,bottom四个位置的填充长度。

    二、实例说明

    import torch
    input = torch.arange(16, dtype=torch.float).reshape(4, 4)
    print(input)
    input = input.unsqueeze(0)
    input = input.unsqueeze(0)
    pad2 = torch.nn.ReflectionPad2d(3)
    res2 = pad2(input)
    print(res2[0][0][:])
    

    以红色框中数据为起点,按照先左右后上下的顺序完成数据的填充。

  • 相关阅读:
    zoj 2812
    按1的个数排序
    输出等腰梯形
    约瑟夫环杂题
    九度oj 题目1369:字符串的排列
    .NET CORE LOG
    .NET CORE 配置
    dotnet core 数据库
    asp.net core mvc简介
    dotnet core 项目
  • 原文地址:https://www.cnblogs.com/leimu/p/13292960.html
Copyright © 2011-2022 走看看