資源簡介
TensorFlow DNNRegressor的簡單使用,包括代碼和所生成的用于 TensorBoard 可視化的文件
代碼片段和文件信息
#?coding:?utf-8
#?詳細可以參考?http://blog.csdn.net/u010099080/article/details/72824899
import?numpy?as?np
import?pandas?as?pd
import?tensorflow?as?tf
from?sklearn.datasets?import?load_boston
from?sklearn.model_selection?import?train_test_split
import?matplotlib.pyplot?as?plt
import?seaborn?as?sns
boston?=?load_boston()
boston_df?=?pd.Dataframe(np.c_[boston.data?boston.target]?columns=np.append(boston.feature_names?‘MEDV‘))
LABEL_COLUMN?=?[‘MEDV‘]
FEATURE_COLUMNS?=?[f?for?f?in?boston_df?if?not?f?in?LABEL_COLUMN]
X_train?X_test?y_train?y_test?=?train_test_split(boston_df[FEATURE_COLUMNS]?boston_df[LABEL_COLUMN]?test_size=0.3)
print(‘訓練集:{}\n測試集:{}‘.format(X_train.shape?X_test.shape))
#?##?定義?FeatureColumns
feature_cols?=?[tf.contrib.layers.real_valued_column(k)?for?k?in?FEATURE_COLUMNS]
#?##?定義?regressor
config?=?tf.contrib.learn.RunConfig(gpu_memory_fraction=0.3?log_device_placement=False)
regressor?=?tf.contrib.learn.DNNRegressor(feature_columns=feature_cols?
???????????????
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件???????1775??2017-06-02?22:04??TensorFlow-DNNRegressor\boston-tensorflow-dnnregressor.py
?????文件????????130??2017-06-02?21:17??TensorFlow-DNNRegressor\dnnregressor\checkpoint
?????文件?????146040??2017-06-02?21:17??TensorFlow-DNNRegressor\dnnregressor\eval\events.out.tfevents.1496409475.ALAN-MIBOOKAIR
?????文件?????194312??2017-06-02?18:20??TensorFlow-DNNRegressor\dnnregressor\events.out.tfevents.1496398833.ALAN-MIBOOKAIR
?????文件?????661725??2017-06-02?21:17??TensorFlow-DNNRegressor\dnnregressor\events.out.tfevents.1496409457.ALAN-MIBOOKAIR
?????文件?????336765??2017-06-02?21:17??TensorFlow-DNNRegressor\dnnregressor\graph.pbtxt
?????文件?????337198??2017-06-02?18:20??TensorFlow-DNNRegressor\dnnregressor\graph.pbtxt.tmp54df31fd23424c2db67693d4ae89b347
?????文件??????74772??2017-06-02?21:17??TensorFlow-DNNRegressor\dnnregressor\model.ckpt-1.data-00000-of-00001
?????文件????????596??2017-06-02?21:17??TensorFlow-DNNRegressor\dnnregressor\model.ckpt-1.index
?????文件?????133112??2017-06-02?21:17??TensorFlow-DNNRegressor\dnnregressor\model.ckpt-1.me
?????文件??????74772??2017-06-02?21:17??TensorFlow-DNNRegressor\dnnregressor\model.ckpt-5000.data-00000-of-00001
?????文件????????596??2017-06-02?21:17??TensorFlow-DNNRegressor\dnnregressor\model.ckpt-5000.index
?????文件?????133112??2017-06-02?21:17??TensorFlow-DNNRegressor\dnnregressor\model.ckpt-5000.me
????..AD...?????????0??2017-06-02?21:52??TensorFlow-DNNRegressor\dnnregressor\eval
????..AD...?????????0??2017-06-02?21:52??TensorFlow-DNNRegressor\dnnregressor
????..AD...?????????0??2017-06-02?21:52??TensorFlow-DNNRegressor
-----------?---------??----------?-----??----
??????????????2094905????????????????????16
評論
共有 條評論