線形レイヤーを積み重ねる
入力から隠れ層を経て出力に至る流れを学びます
「線形レイヤーを積み重ねる」はCoddyKit上の無料Deep Learning Academyレッスンです。 これはレッスン2/4です。 下記で完全なレッスンを無料で読むことができます。その後、ブラウザ内の組み込みコードエディタと24時間対応のAIチューターでハンズオン演習できます。 これはDeep Learning Academy学習パスの一部であり、ウェブとCoddyKitアプリ全体で進捗が同期されます。 Deep Learning Academyコースには全4レッスンが含まれています。
このレッスンの一部はまだ翻訳されておらず、英語で表示されています。
One Layer, One Transform
A single nn.Linear layer maps inputs to outputs with a weighted sum plus a bias. It reshapes data from one size to another.
layer = nn.Linear(in_features=4, out_features=8)Input to Hidden
Your first layer takes the raw input features and projects them into a hidden space, often a larger or smaller width.
self.fc1 = nn.Linear(4, 16) # 4 inputs -> 16 hiddenHidden to Output
A later layer maps the hidden features down to your final output size, like the number of classes you want to predict.
self.fc2 = nn.Linear(16, 3) # 16 hidden -> 3 classesChaining Sizes
Each layer's out_features must equal the next layer's in_features. These matching dimensions form a clean pipeline.
Add a Nonlinearity Between
Stacking bare linear layers stays linear, so place an activation like ReLU between them to unlock real depth.
x = F.relu(self.fc1(x))
x = self.fc2(x)Width Versus Depth
More neurons per layer means more width; more layers means more depth. Both add capacity in different ways.
The Hidden Dimension Choice
Picking the hidden size is a design call. Bigger learns more patterns but costs memory and risks overfitting.
Data Flows Top to Bottom
In forward, the input passes through layer one, then the activation, then layer two. Each step transforms the tensor in turn.
def forward(self, x):
x = F.relu(self.fc1(x))
return self.fc2(x)A Two-Layer MLP
Input, hidden, output with a nonlinearity is the classic multilayer perceptron. It is the workhorse of feedforward nets.
Parameters Grow With Layers
Every linear layer adds its own weights and bias. Stacking more layers steadily grows the model's parameter count.
Start Small, Then Grow
Begin with one hidden layer and expand only if needed. A lean stack trains fast and is easy to debug. 🌱
Quick Check
Recall what must sit between two linear layers to make stacking worthwhile.
Recap
Stack nn.Linear layers so each output size feeds the next input size, with an activation between them. That builds a real MLP. 🎯
よくある質問
「線形レイヤーを積み重ねる」レッスンは無料ですか?
はい。「線形レイヤーを積み重ねる」の完全なテキストはこのウェブで無料で読めます。インタラクティブに演習し(組み込みコードエディタと24時間対応のAIチューター)、Deep Learning Academyコースの残りをアンロックするには、CoddyKit PROにアップグレードしてください。 Deep Learning Academyコースには全4レッスンが含まれています。
「線形レイヤーを積み重ねる」で何を学びますか?
入力から隠れ層を経て出力に至る流れを学びます ブラウザで直接実行するハンズオンコードでDeep Learning Academyを演習し、24時間対応のAIチューターがレッスンを進める中での質問に答えます。
Deep Learning Academyを始めるのに経験は必要ですか?
事前経験は必要ありません。CoddyKitのDeep Learning Academyは初級者から上級者向けに構成されているため、ここから始めるか最初から始めて、自分のペースで進むことができます。 これはレッスン2/4です。
「線形レイヤーを積み重ねる」レッスンにはどのくらい時間がかかりますか?
ほとんどのCoddyKitレッスンは約5~10分かかります。各レッスンはコンパクトでインタラクティブなので、着実に進歩し、ウェブとアプリ全体で正確に前回の場所から再開できます。
このDeep Learning Academyレッスンでコードを書いて実行できますか?
はい。すべてのDeep Learning Academyレッスンに組み込みコードエディタが含まれているため、ブラウザでリアルコードを書いて実行し、即座のAIフィードバックを取得できます。ローカル設定は不要です。