PyTorch torch.quantized_max_pool1d 関数


Pytorch torch 参考手册Pytorch torch リファレンスマニュアル

torch.quantized_max_pool1dPyTorchにおいて、量子化テンソルに対して1次元最大プーリング操作を実行するための関数です。この関数は、量子化畳み込みニューラルネットワークにおいてダウンサンプリングに使用されます。

関数定義

torch.quantized_max_pool1d(input, kernel_size, stride, padding, dilation)

パラメータ説明

  • input: 入力の量子化テンソル(3D: batch x channel x length)
  • kernel_size: プーリングウィンドウのサイズ
  • stride: ストライド(オプション)
  • padding: パディング(オプション)
  • dilation: ダイレーション(オプション)

使用例

実例

import torch

# 量子化入力テンソルを作成 (batch=1, channel=1, length=10)
input = torch.quantize_per_tensor(torch.randn(1, 1, 10), scale=0.1, zero_point=0, dtype=torch.quint8)

# 量子化最大プーリングを実行
output = torch.quantized_max_pool1d(input, kernel_size=3, stride=2, padding=1)

print("入力形状:", input.shape)
print("出力形状:", output.shape)

出力結果は次のとおりです:

输入形状: torch.Size([1, 1, 10])
输出形状: torch.Size([1, 1, 5])

Pytorch torch 参考手册Pytorch torch リファレンスマニュアル

その他の拡張