keras 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. #!/bin/bash
  2. set -e
  3. pushd $(cd $(dirname ${0})/..; pwd) > /dev/null
  4. case "${OSTYPE}" in
  5. msys*) python="winpty python";;
  6. *) python="python";;
  7. esac
  8. venv() {
  9. env_dir=./third_party/env/keras
  10. [ -d "${env_dir}" ] || ${python} -m venv ${env_dir}
  11. case "${OSTYPE}" in
  12. msys*) source ${env_dir}/Scripts/activate;;
  13. *) source ${env_dir}/bin/activate;;
  14. esac
  15. ${python} -m pip install --quiet --upgrade pip
  16. }
  17. clean() {
  18. echo "keras clean"
  19. rm -rf "./third_party/env/keras"
  20. rm -rf "./third_party/source/keras"
  21. }
  22. sync() {
  23. echo "keras sync"
  24. [ -d "./third_party/source/keras" ] || git clone --quiet https://github.com/keras-team/keras.git "./third_party/source/keras"
  25. git -C "./third_party/source/keras" pull --quiet --prune
  26. }
  27. install() {
  28. echo "keras install"
  29. venv
  30. ${python} -m pip install --quiet --upgrade packaging
  31. ${python} -m pip install --quiet --upgrade scikit-learn
  32. ${python} -m pip install --quiet --upgrade keras-nightly
  33. ${python} -m pip install --quiet --upgrade jax
  34. deactivate
  35. }
  36. metadata() {
  37. echo "keras metadata"
  38. venv
  39. if [[ $(grep -U $'\x0D' ./source/keras-metadata.json) ]]; then crlf=1; else crlf=; fi
  40. ${python} ./tools/keras_script.py
  41. if [[ -n ${crlf} ]]; then
  42. unix2dos --quiet --newfile ./source/keras-metadata.json ./source/keras-metadata.json
  43. fi
  44. deactivate
  45. }
  46. while [ "$#" != 0 ]; do
  47. command="$1" && shift
  48. case "${command}" in
  49. "clean") clean;;
  50. "sync") sync;;
  51. "install") install;;
  52. "metadata") metadata;;
  53. esac
  54. done