Register
Login
Resources
Docs Blog Datasets Glossary Case Studies Tutorials & Webinars
Product
Data Engine LLMs Platform Enterprise
Pricing Explore
Connect to our Discord channel

mlutils.py 1.8 KB

You have to be logged in to leave a comment. Sign In
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
  1. import numpy as np
  2. import matplotlib.image as mpimg
  3. from matplotlib import pyplot as plt
  4. from tensorflow.keras.utils import plot_model
  5. import tensorflow as tf
  6. from keras import layers
  7. import keras
  8. import platform
  9. import subprocess
  10. import os
  11. from datetime import datetime
  12. import logging
  13. import coloredlogs
  14. coloredlogs.install(level='INFO')
  15. log = logging.getLogger('mlutils')
  16. def timestamp():
  17. return datetime.now().strftime("%Y-%d-%m_%H-%M-%S-%f-")
  18. def git_version():
  19. def _minimal_ext_cmd(cmd):
  20. # construct minimal environment
  21. env = {}
  22. for k in ['SYSTEMROOT', 'PATH', 'HOME']:
  23. v = os.environ.get(k)
  24. if v is not None:
  25. env[k] = v
  26. # LANGUAGE is used on win32
  27. env['LANGUAGE'] = 'C'
  28. env['LANG'] = 'C'
  29. env['LC_ALL'] = 'C'
  30. out = subprocess.check_output(cmd, stderr=subprocess.STDOUT, env=env)
  31. return out
  32. try:
  33. out = _minimal_ext_cmd(['git', 'rev-parse', '--short', 'HEAD'])
  34. GIT_REVISION = out.strip().decode('ascii')
  35. except (subprocess.SubprocessError, OSError):
  36. GIT_REVISION = "Unknown"
  37. if not GIT_REVISION:
  38. # this shouldn't happen but apparently can (see gh-8512)
  39. GIT_REVISION = "Unknown"
  40. return GIT_REVISION
  41. def mlversion():
  42. from IPython.core.interactiveshell import InteractiveShell
  43. InteractiveShell.ast_node_interactivity = "all"
  44. from keras import models
  45. strategy = tf.distribute.MirroredStrategy()
  46. log.info("python version :" + platform.python_version())
  47. log.info("keras version :" + keras.__version__)
  48. log.info("tensorflow version :" + tf.__version__)
  49. log.info("Number of GPU devices: {}".format(strategy.num_replicas_in_sync))
  50. log.info(tf.config.list_physical_devices('GPU'))
  51. log.info(tf.sysconfig.get_lib())
Tip!

Press p or to see the previous file or, n or to see the next file

Comments

Loading...