(三)高階api: estimator
流程:假設存在合適的預建立的 estimator,使用它構建模型。
訓練模型
評估模型
可以通過構建自定義 estimator 進一步改進模型
1)例項化相關的預建立的 estimator。
可以指定優化演算法,模型結構。不同的模型,建立estimator參考api.estimator = tf.estimator.linearclassifier(
feature_columns=[population, crime_rate, median_education],
)
2)訓練estimator = dnnclassifier(
feature_columns=[categorical_feature_a_emb, categorical_feature_b_emb],
hidden_units=[1024, 512, 256],
optimizer=tf.train.proximaladagradoptimizer(
learning_rate=0.1,
l1_regularization_strength=0.001
))
estimator.train(input_fn=my_training_set, steps=2000)
3)**與評估
estimator.evaluate(input_fn=my_predict_set)
estimator.predict(input_fn=my_predict_set)
tensorflow學習筆記
tensorflow安裝可以直接通過命令列或者原始碼安裝,在此介紹tensorflow8命令列安裝如下 安裝tensorflow sudo pip install upgrade 另外,解除安裝tensorflow命令為 sudo pip uninstall tensorflow tensorflo...
Tensorflow學習筆記
1.如何在虛擬機器中安裝tensor flow 1 首先安裝pip pip install 2 pip install 2.學習tensorflow需要學習 python and linux 3.使用 tensorflow,你必須明白 tensorflow 1 使用圖 graph 來表示計算任務.2...
TensorFlow學習筆記
1 擬合直線 import the library import tensorflow as tf import numpy as np prepare train data train x np.linspace 1,1,100 temp1 train x,temp2 train x.shape,...