You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

dataset.py 995 B

123456789101112131415161718192021222324252627282930313233343536
  1. import collections
  2. import os
  3. import time
  4. import matplotlib.pyplot as plt
  5. import numpy as np
  6. import uctc.nn as nn
  7. use_graphics = True
  8. def maybe_sleep_and_close(seconds):
  9. if use_graphics and plt.get_fignums():
  10. time.sleep(seconds)
  11. for fignum in plt.get_fignums():
  12. fig = plt.figure(fignum)
  13. plt.close(fig)
  14. try:
  15. # This raises a TclError on some Windows machines
  16. fig.canvas.start_event_loop(1e-3)
  17. except:
  18. pass
  19. def get_data_path(filename):
  20. path = os.path.join(
  21. os.path.dirname(__file__), os.pardir, "data", filename)
  22. if not os.path.exists(path):
  23. path = os.path.join(
  24. os.path.dirname(__file__), "data", filename)
  25. if not os.path.exists(path):
  26. path = os.path.join(
  27. os.path.dirname(__file__), filename)
  28. if not os.path.exists(path):
  29. raise Exception("Could not find data file: {}".format(filename))
  30. return path