Skip to Content
PyTorch によるコーダーのための AI および ML
book

PyTorch によるコーダーのための AI および ML

by Laurence Moroney
July 2025
Intermediate to advanced
444 pages
7h 8m
Japanese
O'Reilly Media, Inc.
Content preview from PyTorch によるコーダーのための AI および ML

第11章. シーケンスモデルに畳み込み法とリカレント法を使う

この作品はAIを使って翻訳されている。ご意見、ご感想をお待ちしている:translation-feedback@oreilly.com

ここ数章で、シーケンスデータを紹介した。まず統計的メソッドを使い、次にディープニューラルネットワークを使った基本的なMLメソッドを使う。また、より良い性能を得るためにモデルのハイパーパラメータを調整する方法を探った。

この章では、リカレントニューラルネットワークだけでなく、畳み込みニューラルネットワークを使用することで、シーケンスデータを予測する能力をさらに向上させる可能性のある追加テクニックを見ていく。

シーケンスデータのための畳み込み

第3章では、 、2次元(2D)フィルタリングが画像に渡され、画像を修正し、特徴を抽出する可能性がある畳み込みについて紹介した。時間の経過とともに、ニューラルネットワークはどのフィルタリング値がピクセルに加えられた修正とそのラベルとのマッチングに効果的かを学習し、画像から効果的に特徴を抽出した。同じテクニックが数値の時系列データにも適用できるが、1つだけ変更がある。

例えば、図11-1の数値系列を考えてみよう。

図11-1. 数列

1次元の畳み込みは次のように演算できる。畳み込みは1×3フィルターで、フィルター値はそれぞれ-0.5、1、-0.5とする。この場合、シーケンスの最初の値は失われ、2番目の値は8から-1.5に変換される(図11-2参照)。

図11-2. 数列で畳み込みを使う

フィルタはその後、値をまたぎながら新しい値を計算する。例えば、次のストライドでは15が3に変換される(図11-3参照)。

図11-3. 1次元畳み込みにおける追加のストライド

このメソッドを使えば、画像のピクセルを畳み込んで特徴を抽出するのと同じように、値間のパターンを抽出し、それをうまく抽出するフィルタを学習することができる。このインスタンスンスでは、ラベルは存在しないが、全体の損失を最小にする畳み込みが学習できる。

畳み込みを符号化する

コンボリューションをコーディングする前に、 、第10章で示したように、スライディングウィンドウのテクニックを使ってデータセットを作成する必要がある。コードは本書のGitHubページで入手できる。

データセットを手に入れたら、それまであった密なレイヤーの前に畳み込みレイヤーを追加することができる。これがそのコードで、一行ずつ見ていこう:

class CNN1D(nn.Module):
    def __init__(self, input_size):
        super(CNN1D, self).__init__()
        self.conv1 = nn.Conv1d(in_channels=1,
                              out_channels ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

生成 Deep Learning ―絵を描き、物語や音楽を作り、ゲームをプレイする

生成 Deep Learning ―絵を描き、物語や音楽を作り、ゲームをプレイする

David Foster, 松田 晃一, 小沼 千絵
ダイナミックリチーミング 第2版 ―5つのパターンによる効果的なチーム編成

ダイナミックリチーミング 第2版 ―5つのパターンによる効果的なチーム編成

Heidi Helfand, 永瀬 美穂, 吉羽 龍太郎, 原田 騎郎, 細澤 あゆみ

Publisher Resources

ISBN: 9798341662636