Professional Documents
Culture Documents
Kiemtra 2
Kiemtra 2
Bài 1:
*)Code:
import numpy as np
print(dataset[:5])
*) Kết quả:
[[ 6. 148. 72. 35. 0. 33.6 0.627 50. 1. ]
[ 1. 85. 66. 29. 0. 26.6 0.351 31. 0. ]
[ 8. 183. 64. 0. 0. 23.3 0.672 32. 1. ]
[ 1. 89. 66. 23. 94. 28.1 0.167 21. 0. ]
[ 0. 137. 40. 35. 168. 43.1 2.288 33. 1. ]
]
Bài 2:
*) Code:
import numpy as np
X = dataset[:,0:8]
Y = dataset[:,8]
# create model
model = Sequential()
model.add(Dense(15, input_dim=8, activation='relu'))
model.add(Dense(10, activation='relu'))
model.add(Dense(1, activation='sigmoid'))
# Compile model
print(history.history.keys())
plt.plot(history.history['accuracy'])
plt.plot(history.history['val_accuracy'])
plt.title('model accuracy')
plt.ylabel('accuracy')
plt.xlabel('epoch')
plt.show()
plt.plot(history.history['loss'])
plt.plot(history.history['val_loss'])
plt.title('model loss')
plt.ylabel('loss')
plt.xlabel('epoch')
plt.show()
*)Chạy:
Bài 3:
*)Code:
import numpy as np
X = dataset[:,0:8]
Y = dataset[:,8]
# create model
model = Sequential()
model.add(Dense(15, activation='relu'))
model.add(Dense(10, activation='relu'))
model.add(Dense(18, activation='relu'))
model.add(Dense(1, activation='sigmoid'))
# Compile model
print(history.history.keys())
plt.plot(history.history['accuracy'])
plt.plot(history.history['val_accuracy'])
plt.title('model accuracy')
plt.ylabel('accuracy')
plt.xlabel('epoch')
plt.show()
plt.plot(history.history['loss'])
plt.plot(history.history['val_loss'])
plt.title('model loss')
plt.ylabel('loss')
plt.xlabel('epoch')
plt.show()
*)Chạy:
Bài 4:
*) Mô hình 1:
-)Code:
import numpy as np
Y = dataset[:,8]
# create model
model = Sequential()
model.add(Dropout(0.1))
model.add(Dense(10, activation='relu'))
model.add(Dropout(0.1))
model.add(Dense(1, activation='sigmoid'))
# Compile model
print(history.history.keys())
plt.plot(history.history['accuracy'])
plt.plot(history.history['val_accuracy'])
plt.title('model accuracy')
plt.ylabel('accuracy')
plt.xlabel('epoch')
plt.show()
plt.plot(history.history['loss'])
plt.plot(history.history['val_loss'])
plt.title('model loss')
plt.ylabel('loss')
plt.xlabel('epoch')
plt.legend(['train', 'test'], loc='upper left')
plt.show()
-)Chạy:
*) Mô hình 2:
-) Code:
import numpy as np
X = dataset[:,0:8]
Y = dataset[:,8]
# create model
model = Sequential()
model.add(Dense(15, activation='relu'))
model.add(Dense(10, activation='relu'))
model.add(Dense(18, activation='relu'))
model.add(Dense(1, activation='sigmoid'))
print(history.history.keys())
plt.plot(history.history['accuracy'])
plt.plot(history.history['val_accuracy'])
plt.title('model accuracy')
plt.ylabel('accuracy')
plt.xlabel('epoch')
plt.show()
plt.plot(history.history['val_loss'])
plt.title('model loss')
plt.ylabel('loss')
plt.xlabel('epoch')
plt.show()
-)Chạy:
Bài 5:
- Hình 1:
o Từ biểu đồ về độ chính xác, bạn có thể thấy rằng mô hình có thể được đào tạo thêm một
chút vì xu hướng về độ chính xác trên cả hai tập dữ liệu vẫn đang tăng lên trong vài kỷ
nguyên gần đây. Bạn cũng có thể thấy rằng mô hình vẫn chưa học quá nhiều về tập dữ liệu
huấn luyện, thể hiện kỹ năng tương đương trên cả hai tập dữ liệu.
o Từ biểu đồ tổn thất, bạn có thể thấy rằng mô hình có hiệu suất tương đương trên cả tập
dữ liệu huấn luyện và tập dữ liệu xác thực (kiểm tra được gắn nhãn). Nếu những âm mưu
song song này bắt đầu khởi hành một cách nhất quán, đó có thể là dấu hiệu để ngừng đào
tạo ở thời điểm sớm hơn.
- Hình 1.1:
o Sau khi thêm dropout vào thì tỉ lệ chính xác của biểu đồ cao hơn trên tập test. Nhưng tỉ
lệ chính xác lại không bằng so với khi chưa thêm dropout.
- Hình 2:
o Sau khi thêm lớp vào độ chính xác lại tăng lên.
- Hình 2.1:
o Sau khi thêm dropout vào thì tỉ lệ chính xác của biểu đồ cao hơn trên tập test. Nhưng tỉ
lệ chính xác lại không bằng so với khi chưa thêm dropout.