# TensorFlow 是用於機器學習的端對端開放原始碼平台

#### 適合新手

```import tensorflow as tf
mnist = tf.keras.datasets.mnist

x_train, x_test = x_train / 255.0, x_test / 255.0

model = tf.keras.models.Sequential([
tf.keras.layers.Flatten(input_shape=(28, 28)),
tf.keras.layers.Dense(128, activation='relu'),
tf.keras.layers.Dropout(0.2),
tf.keras.layers.Dense(10, activation='softmax')
])

loss='sparse_categorical_crossentropy',
metrics=['accuracy'])

model.fit(x_train, y_train, epochs=5)
model.evaluate(x_test, y_test)
```

#### 適合專家

Subclassing API 提供依據執行情況動態定義 (define-by-run) 的介面，可用於進階研究。先建立模型的類別，然後寫入必要的正向傳遞。輕鬆撰寫自訂層、啟動項目，以及訓練迴圈。請執行下方的「Hello World」範例，然後前往 教學課程 瞭解詳情。

```class MyModel(tf.keras.Model):
def __init__(self):
super(MyModel, self).__init__()
self.conv1 = Conv2D(32, 3, activation='relu')
self.flatten = Flatten()
self.d1 = Dense(128, activation='relu')
self.d2 = Dense(10, activation='softmax')

def call(self, x):
x = self.conv1(x)
x = self.flatten(x)
x = self.d1(x)
return self.d2(x)
model = MyModel()

logits = model(images)
loss_value = loss(logits, labels)
```

## 常見問題的解決方案

Neural machine translation with attention

## 最新消息與公告

Check out our blog for additional updates, and subscribe to our TensorFlow newsletter to get the latest announcements sent directly to your inbox.

## 參與社群

[{ "type": "thumb-down", "id": "missingTheInformationINeed", "label":"缺少我需要的資訊" },{ "type": "thumb-down", "id": "tooComplicatedTooManySteps", "label":"過於複雜/步驟過多" },{ "type": "thumb-down", "id": "outOfDate", "label":"過時" },{ "type": "thumb-down", "id": "translationIssue", "label":"翻譯問題" },{ "type": "thumb-down", "id": "samplesCodeIssue", "label":"示例/程式碼問題" },{ "type": "thumb-down", "id": "otherDown", "label":"其他" }]
[{ "type": "thumb-up", "id": "easyToUnderstand", "label":"容易理解" },{ "type": "thumb-up", "id": "solvedMyProblem", "label":"確實解決了我的問題" },{ "type": "thumb-up", "id": "otherUp", "label":"其他" }]