Tensorflow เป็นเฟรมเวิร์ก Machine Learning ที่ Google มอบให้ เป็นเฟรมเวิร์ก Open Source ที่ใช้ร่วมกับ Python เพื่อนำอัลกอริทึม Deep Learning Applications และอื่นๆ ไปใช้งาน ใช้ทั้งในการวิจัยและการผลิต
Keras ถูกพัฒนาขึ้นเป็นส่วนหนึ่งของการวิจัยโครงการ ONEIROS (Open ended Neuro-Electronic Intelligent Robot Operating System) Keras เป็น Deep Learning API ที่เขียนด้วย Python เป็น High-level API ที่มี Interface 产品化 ช่วยแก้ปัญหา Machine Learning ได้อย่างมีประสิทธิภาพ
มันมีความสามารถในการ Scale สูง และมีความสามารถ Cross-platform หมายความว่า Keras รันบน TPU หรือ Cluster ของ GPUs ได้ โมเดล Keras ยังสามารถ Export ไปรันบน Web Browser หรือ Mobile Phone ได้อีกด้วย
Keras อยู่ภายในแพ็กเกจ Tensorflow แล้ว สามารถเข้าถึงได้ด้วยโค้ดด้านล่าง
import tensorflow from tensorflow import keras
เราใช้ Google Colaboratory รันโค้ดด้านล่าง Google Colab ช่วยรัน Python Code บนเบราว์เซอร์ ต้องการการตั้งค่าศูนย์ และเข้าถึง GPU ฟรี Colaboratory สร้างบน Jupyter Notebook
โค้ดต่อไปนี้สำหรับลบ Layers
ตัวอย่าง
print("Removing layers using the pop function")
model.pop()
print("The current number of layers in the model after eliminating one layer")
print(len(model.layers))
Code credit - https://www.tensorflow.org/guide/keras/sequential_model
ผลลัพธ์
Removing layers using the pop function The current number of layers in the model after eliminating one layer 2
คำอธิบาย
ฟังก์ชัน 'pop' สามารถเรียกได้โดยเชื่อมชื่อโมเดลกับฟังก์ชันด้วย Dot Operator
หลังจากนั้น สามารถตรวจสอบความยาวของ Layers ได้
สิ่งนี้จะช่วยยืนยันว่า Layer หนึ่งถูกลบจริงๆ