Yuchan
commited on
Update Mo.py
Browse files
Mo.py
CHANGED
|
@@ -245,7 +245,6 @@ def masked_perplexity(y_true, y_pred, eps=0.1):
|
|
| 245 |
mean_loss = tf.reduce_sum(per_tok) / (tf.reduce_sum(mask) + 1e-8)
|
| 246 |
return tf.exp(mean_loss)
|
| 247 |
|
| 248 |
-
|
| 249 |
# =======================
|
| 250 |
# 모델 생성 & 컴파일
|
| 251 |
# =======================
|
|
@@ -261,10 +260,8 @@ with strategy.scope():
|
|
| 261 |
# 학습
|
| 262 |
history = model.fit(dist_dataset, epochs=1, verbose=1)
|
| 263 |
|
| 264 |
-
|
| 265 |
-
|
| 266 |
-
model.save_weights("model.weights.h5")
|
| 267 |
-
print("모델 가중치 저장 완료!")
|
| 268 |
|
| 269 |
def generate_text_topp(model, prompt, max_len=512, max_gen=512, p=0.9, temperature=0.8, min_len=20):
|
| 270 |
model_input = text_to_ids(f"<start> {prompt}")
|
|
|
|
| 245 |
mean_loss = tf.reduce_sum(per_tok) / (tf.reduce_sum(mask) + 1e-8)
|
| 246 |
return tf.exp(mean_loss)
|
| 247 |
|
|
|
|
| 248 |
# =======================
|
| 249 |
# 모델 생성 & 컴파일
|
| 250 |
# =======================
|
|
|
|
| 260 |
# 학습
|
| 261 |
history = model.fit(dist_dataset, epochs=1, verbose=1)
|
| 262 |
|
| 263 |
+
model.save_weights("tf_model.weights.h5")
|
| 264 |
+
print("✅ 모델 가중치 저장 완료!")
|
|
|
|
|
|
|
| 265 |
|
| 266 |
def generate_text_topp(model, prompt, max_len=512, max_gen=512, p=0.9, temperature=0.8, min_len=20):
|
| 267 |
model_input = text_to_ids(f"<start> {prompt}")
|