開始使用免費開始

在 PyTorch 建立二元分類器

回想一下,由單一線性層接著 sigmoid 函式組成的小型神經網路,就是一個二元分類器。它的行為就像邏輯斯迴歸。

練習建立這個小型網路,並解讀分類器的輸出。

本練習屬於課程

使用 PyTorch 的深度學習入門

檢視課程

動手互動練習

試著完成這個範例程式碼,體驗一下這個練習。

import torch
import torch.nn as nn

input_tensor = torch.Tensor([[3, 4, 6, 2, 3, 6, 8, 9]])

# Implement a small neural network for binary classification
model = nn.Sequential(
  nn.____(____),
  nn.____()
)

output = model(input_tensor)
print(output)
編輯並執行程式碼