# 載入模型(reload model)
## 使用:
~~~
# 參數模型所在路徑,不為空框架會加載模型,用于預測或繼續訓練
"load_model": "AA-1000.model"
~~~
## 參數說明:
load_model:參數模型所在路徑,不為空框架會加載模型,用于預測或繼續訓練
## 完整例子
~~~
# 加載模型,直接預測
# pip install AADeepLearning
from AADeepLearning import AADeepLearning
from AADeepLearning.datasets import mnist
from AADeepLearning.datasets import np_utils
# mnist數據集已經被劃分成了60,000個訓練集,10,000個測試集的形式,如果數據不存在則自動下載
(x_train, y_train), (x_test, y_test) = mnist.load_data()
# 第一個維度是樣本數目,第二維度是通道數表示顏色通道數,第三維度是高,第四個維度是寬
x_train = x_train.reshape(x_train.shape[0], 1, 28, 28)
x_test = x_test.reshape(x_test.shape[0], 1, 28, 28)
# 將x_train, x_test的數據格式轉為float32
x_train = x_train.astype('float32')
x_test = x_test.astype('float32')
# 歸一化,將值映射到 0到1區間
x_train /= 255
x_test /= 255
# 因為是10分類,所以將類別向量(從0到10的整數向量)映射為二值類別矩陣,相當于將向量用one-hot重新編碼
y_train = np_utils.to_categorical(y_train, 10)
y_test = np_utils.to_categorical(y_test, 10)
# 網絡配置文件
config = {
# 參數模型所在路徑,不為空框架會加載模型,用于預測或繼續訓練
"load_model": "AA-1000.model"
}
# 定義模型,傳入配置項
AA = AADeepLearning(config=config)
# 使用測試集預測,返回概率分布和準確率, score:樣本在各個分類上的概率, accuracy:準確率
score, accuracy = AA.predict(x_test=x_test, y_test=y_test)
print("test set accuracy:", accuracy)
~~~
- 序言
- 安裝
- 快速體驗
- 配置
- 層(layer)
- 展平(flatten)
- 全連接(fully connected)
- 卷積(convolutional)
- 池化(pooling)
- 標準化(batch normalization)
- 失活(dropout)
- 循環(RNN)
- 長短期記憶(LSTM)
- 激活函數(activation)
- relu
- sigmoid
- tanh
- 損失(loss)
- 交叉熵損失(softmax)
- 折頁損失(SVM或Hinge)
- 優化器(optimizer)
- 帶動量學習率自適應(adam)
- 動量(momentum)
- 學習率自適應(rmsprop)
- 隨機梯度下降(sgd)
- 模型(model)
- 保存(save)
- 載入(reload)
- 繼續訓練(continue train)
- 數據集(datasets)
- 手寫數字(mnist)
- 時尚物品(Fashion-MNIST)
- 10種物體分類(cifar10)
- 100種物體分類(cifar100)
- 電影評論情感分類(imdb)
- 路透社新聞主題分類(reuters)
- 可視化(visualization)
- 損失曲線(loss)
- 準確率曲線(accuracy)