แนวคิด
สร้าง Estimator ด้วย DNNClassifier ใน tf.estimator
ใช้ Keras Sequential API, CNN, TensorFlow Text, Google Colab, Estimator, Iris dataset เหมือนเดิม
ตัวอย่างโค้ด
print("Build a DNN that has 2 hidden layers with 30 and 10 hidden nodes each")
classifier = tf.estimator.DNNClassifier(
feature_columns=my_feature_columns,
hidden_units=[30, 10],
n_classes=3)
Credit: TensorFlow Tutorials
ผลลัพธ์
Build a DNN that has 2 hidden layers with 30 and 10 hidden nodes each
INFO:tensorflow:Using default config.
WARNING:tensorflow:Using temporary folder as model directory: /tmp/tmpdh8866zb
INFO:tensorflow:Using config: {...}
คำอธิบาย
- ปัญหา Iris เป็น classification problem
- TensorFlow มี pre-made classifier Estimators:
tf.estimator.DNNClassifierสำหรับโมเดลลึก multi-classtf.estimator.DNNLinearCombinedClassifierwide & deeptf.estimator.LinearClassifierlinear models
- สำหรับ Iris ใช้
tf.estimator.DNNClassifier