|
|
|
|
|
|
|
|
|
|
|
|
|
|
import os
|
|
|
from pathlib import Path
|
|
|
from tensorboard.backend.event_processing import event_accumulator
|
|
|
|
|
|
def export_tensorboard_logs_to_text(log_dir: str):
|
|
|
"""์ง์ ๋ ๋๋ ํ ๋ฆฌ์์ TensorBoard ์ด๋ฒคํธ ํ์ผ์ ์ฐพ์ ์ค์นผ๋ผ ๊ฐ์ ์ถ๋ ฅํฉ๋๋ค."""
|
|
|
log_path = Path(log_dir)
|
|
|
if not log_path.exists() or not log_path.is_dir():
|
|
|
print(f"[์๋ฌ] ๋ก๊ทธ ๋๋ ํ ๋ฆฌ๋ฅผ ์ฐพ์ ์ ์์ต๋๋ค: {log_dir}")
|
|
|
return
|
|
|
|
|
|
print(f"--- 6. TensorBoard Log Export ---")
|
|
|
print(f"๋์ ๋๋ ํ ๋ฆฌ: {log_dir}")
|
|
|
|
|
|
try:
|
|
|
event_file = next(log_path.glob("events.out.tfevents.*"))
|
|
|
except StopIteration:
|
|
|
print(f"[์๋ฌ] '{log_dir}'์์ ์ด๋ฒคํธ ํ์ผ์ ์ฐพ์ ์ ์์ต๋๋ค.")
|
|
|
return
|
|
|
|
|
|
acc = event_accumulator.EventAccumulator(str(event_file), size_guidance={'scalars': 0})
|
|
|
acc.Reload()
|
|
|
scalar_tags = acc.Tags()['scalars']
|
|
|
|
|
|
print(f"\n์ถ์ถ๋ ์งํ: {scalar_tags}")
|
|
|
print("-" * 40)
|
|
|
|
|
|
for tag in sorted(scalar_tags):
|
|
|
events = acc.Scalars(tag)
|
|
|
print(f"\n[์งํ: {tag}]")
|
|
|
print(" Step | Value")
|
|
|
print("-------|---------")
|
|
|
for event in events:
|
|
|
print(f" {event.step:<5} | {event.value:.6f}")
|
|
|
|
|
|
print("\n--- ๋ถ์ ์๋ฃ ---")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
|
|
target_log_directory = "./logs"
|
|
|
export_tensorboard_logs_to_text(target_log_directory)
|
|
|
|