3-backend.py 996 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. """
  2. To know more or get code samples, please visit my website:
  3. https://mofanpy.com/tutorials/
  4. Or search: 莫烦Python
  5. Thank you for supporting!
  6. """
  7. # please note, all tutorial code are running under python3.5.
  8. # If you use the version like python2.7, please modify the code accordingly
  9. # 3 - backend
  10. """
  11. Details are showing in the video.
  12. ----------------------
  13. Method 1:
  14. If you have run Keras at least once, you will find the Keras configuration file at:
  15. ~/.keras/keras.json
  16. If it isn't there, you can create it.
  17. The default configuration file looks like this:
  18. {
  19. "image_dim_ordering": "tf",
  20. "epsilon": 1e-07,
  21. "floatx": "float32",
  22. "backend": "theano"
  23. }
  24. Simply change the field backend to either "theano" or "tensorflow",
  25. and Keras will use the new configuration next time you run any Keras code.
  26. ----------------------------
  27. Method 2:
  28. define this before import keras:
  29. >>> import os
  30. >>> os.environ['KERAS_BACKEND']='theano'
  31. >>> import keras
  32. Using Theano backend.
  33. """