diff options
Diffstat (limited to 'gnu/packages/machine-learning.scm')
-rw-r--r-- | gnu/packages/machine-learning.scm | 146 |
1 files changed, 64 insertions, 82 deletions
diff --git a/gnu/packages/machine-learning.scm b/gnu/packages/machine-learning.scm index 3185c15aead..ba54e72d12d 100644 --- a/gnu/packages/machine-learning.scm +++ b/gnu/packages/machine-learning.scm @@ -16,7 +16,7 @@ ;;; Copyright © 2020 Konrad Hinsen <konrad.hinsen@fastmail.net> ;;; Copyright © 2020 Edouard Klein <edk@beaver-labs.com> ;;; Copyright © 2020, 2021 Vinicius Monego <monego@posteo.net> -;;; Copyright © 2020 Maxim Cournoyer <maxim.cournoyer@gmail.com> +;;; Copyright © 2020, 2021 Maxim Cournoyer <maxim.cournoyer@gmail.com> ;;; ;;; This file is part of GNU Guix. ;;; @@ -222,20 +222,7 @@ classification.") #:phases (modify-phases %standard-phases (add-after 'unpack 'enter-dir - (lambda _ (chdir "ghmm") #t)) - (delete 'check) - (add-after 'install 'check - (assoc-ref %standard-phases 'check)) - (add-before 'check 'fix-PYTHONPATH - (lambda* (#:key inputs outputs #:allow-other-keys) - (let ((python-version (python-version - (assoc-ref inputs "python")))) - (setenv "PYTHONPATH" - (string-append (getenv "PYTHONPATH") - ":" (assoc-ref outputs "out") - "/lib/python" python-version - "/site-packages"))) - #t)) + (lambda _ (chdir "ghmm"))) (add-after 'enter-dir 'fix-runpath (lambda* (#:key outputs #:allow-other-keys) (substitute* "ghmmwrapper/setup.py" @@ -246,8 +233,7 @@ classification.") line "\"-Wl,-rpath=" (assoc-ref outputs "out") - "/lib\", "))) - #t)) + "/lib\", "))))) (add-after 'enter-dir 'disable-broken-tests (lambda _ (substitute* "tests/Makefile.am" @@ -267,8 +253,7 @@ classification.") line indent) (string-append indent "@unittest.skip(\"Disabled by Guix\")\n" - line))) - #t))))) + line)))))))) (inputs `(("python" ,python-2) ; only Python 2 is supported ("libxml2" ,libxml2))) @@ -946,7 +931,7 @@ computing environments.") (define-public python-scikit-learn (package (name "python-scikit-learn") - (version "0.24.2") + (version "1.0.1") (source (origin (method git-fetch) @@ -956,7 +941,7 @@ computing environments.") (file-name (git-file-name name version)) (sha256 (base32 - "0hm92biqwwc87bqnr56lwa5bz77lr7k9q21rdwksnfzq3vsdp2nm")))) + "07k92y78sk4074vh5hp8y63pwl592wgl8azrfp0q84chxk8igfx9")))) (build-system python-build-system) (arguments `(#:phases @@ -964,14 +949,17 @@ computing environments.") (add-after 'build 'build-ext (lambda _ (invoke "python" "setup.py" "build_ext" "--inplace"))) (replace 'check - (lambda _ - ;; Restrict OpenBLAS threads to prevent segfaults while testing! - (setenv "OPENBLAS_NUM_THREADS" "1") + (lambda* (#:key tests? #:allow-other-keys) + (when tests? + ;; Restrict OpenBLAS threads to prevent segfaults while testing! + (setenv "OPENBLAS_NUM_THREADS" "1") - ;; Some tests require write access to $HOME. - (setenv "HOME" "/tmp") + ;; Some tests require write access to $HOME. + (setenv "HOME" "/tmp") - (invoke "pytest" "sklearn" "-m" "not network"))) + (invoke "pytest" "sklearn" "-m" "not network" + ;; This test tries to access the internet. + "-k" "not test_load_boston_alternative")))) (add-before 'reset-gzip-timestamps 'make-files-writable (lambda* (#:key outputs #:allow-other-keys) ;; Make sure .gz files are writable so that the @@ -1647,7 +1635,7 @@ automatically.") (let* ((server (string-append bin "/kaldi-gst-server")) (client (string-append bin "/kaldi-gst-client")) (worker (string-append bin "/kaldi-gst-worker")) - (PYTHONPATH (getenv "PYTHONPATH")) + (PYTHONPATH (getenv "GUIX_PYTHONPATH")) (GST_PLUGIN_PATH (string-append (assoc-ref inputs "gst-kaldi-nnet2-online") "/lib/gstreamer-1.0:${GST_PLUGIN_PATH}")) @@ -1656,7 +1644,7 @@ automatically.") (lambda _ (format #t "#!~a -export PYTHONPATH=~a +export GUIX_PYTHONPATH=~a export GST_PLUGIN_PATH=~a exec ~a ~a/~a \"$@\"~%" (which "bash") PYTHONPATH GST_PLUGIN_PATH @@ -1750,7 +1738,7 @@ Python.") ((guix build python-build-system) #:select (python-version))) #:imported-modules (,@%cmake-build-system-modules - (guix build python-build-system)) + (guix build python-build-system)) #:phases (modify-phases %standard-phases (add-after 'unpack 'set-source-file-times-to-1980 @@ -1780,10 +1768,9 @@ Python.") ;; https://github.com/tensorflow/tensorflow/issues/34197 (substitute* (find-files "tensorflow/python" ".*\\.cc$") (("(nullptr,)(\\ +/. tp_print)" _ _ tp_print) - (string-append "NULL, " tp_print))) - #t)) + (string-append "NULL, " tp_print))))) (add-after 'python3.7-compatibility 'chdir - (lambda _ (chdir "tensorflow/contrib/cmake") #t)) + (lambda _ (chdir "tensorflow/contrib/cmake"))) (add-after 'chdir 'disable-downloads (lambda* (#:key inputs #:allow-other-keys) (substitute* (find-files "external" "\\.cmake$") @@ -1798,36 +1785,31 @@ Python.") ;; Sqlite (("include\\(sqlite\\)") "") (("\\$\\{sqlite_STATIC_LIBRARIES\\}") - (string-append (assoc-ref inputs "sqlite") - "/lib/libsqlite3.so")) + (search-input-file inputs "/lib/libsqlite3.so")) (("sqlite_copy_headers_to_destination") "") ;; PNG (("include\\(png\\)") "") (("\\$\\{png_STATIC_LIBRARIES\\}") - (string-append (assoc-ref inputs "libpng") - "/lib/libpng16.so")) + (search-input-file inputs "/lib/libpng16.so")) (("png_copy_headers_to_destination") "") ;; JPEG (("include\\(jpeg\\)") "") (("\\$\\{jpeg_STATIC_LIBRARIES\\}") - (string-append (assoc-ref inputs "libjpeg") - "/lib/libjpeg.so")) + (search-input-file inputs "/lib/libjpeg.so")) (("jpeg_copy_headers_to_destination") "") ;; GIF (("include\\(gif\\)") "") (("\\$\\{gif_STATIC_LIBRARIES\\}") - (string-append (assoc-ref inputs "giflib") - "/lib/libgif.so")) + (search-input-file inputs "/lib/libgif.so")) (("gif_copy_headers_to_destination") "") ;; lmdb (("include\\(lmdb\\)") "") (("\\$\\{lmdb_STATIC_LIBRARIES\\}") - (string-append (assoc-ref inputs "lmdb") - "/lib/liblmdb.so")) + (search-input-file inputs "/lib/liblmdb.so")) (("lmdb_copy_headers_to_destination") "") ;; Protobuf @@ -1879,8 +1861,7 @@ set(eigen_INCLUDE_DIRS ${CMAKE_CURRENT_BINARY_DIR}/external/eigen_archive " (("tf_core_cpu grpc") "tf_core_cpu")) ;; This directory is a dependency of many targets. - (mkdir-p "protobuf") - #t)) + (mkdir-p "protobuf"))) (add-after 'configure 'unpack-third-party-sources (lambda* (#:key inputs #:allow-other-keys) ;; This is needed to configure bundled packages properly. @@ -1920,8 +1901,7 @@ set(eigen_INCLUDE_DIRS ${CMAKE_CURRENT_BINARY_DIR}/external/eigen_archive " "re2")) (rename-file "../build/cub/src/cub/cub-1.8.0/" - "../build/cub/src/cub/cub/") - #t)) + "../build/cub/src/cub/cub/"))) (add-after 'unpack 'fix-python-build (lambda* (#:key inputs outputs #:allow-other-keys) (mkdir-p "protobuf-src") @@ -1932,9 +1912,6 @@ set(eigen_INCLUDE_DIRS ${CMAKE_CURRENT_BINARY_DIR}/external/eigen_archive " "-C" "eigen-src" "--strip-components=1") (substitute* "tensorflow/contrib/cmake/tf_python.cmake" - ;; Ensure that all Python dependencies can be found at build time. - (("PYTHONPATH=\\$\\{CMAKE_CURRENT_BINARY_DIR\\}/tf_python" m) - (string-append m ":" (getenv "PYTHONPATH"))) ;; Take protobuf source files from our source package. (("\\$\\{CMAKE_CURRENT_BINARY_DIR\\}/protobuf/src/protobuf/src/google") (string-append (getcwd) "/protobuf-src/src/google"))) @@ -1946,7 +1923,7 @@ set(eigen_INCLUDE_DIRS ${CMAKE_CURRENT_BINARY_DIR}/external/eigen_archive " (string-append (getcwd) "/eigen-src/")) ;; Take Eigen headers from our own package. (("\\$\\{CMAKE_CURRENT_BINARY_DIR\\}/external/eigen_archive") - (string-append (assoc-ref inputs "eigen") "/include/eigen3"))) + (search-input-directory inputs "/include/eigen3"))) ;; Correct the RUNPATH of ops libraries generated for Python. ;; TODO: this doesn't work :( @@ -1960,21 +1937,22 @@ set(eigen_INCLUDE_DIRS ${CMAKE_CURRENT_BINARY_DIR}/external/eigen_archive " (string-append "set_target_properties(${_AT_TARGET} PROPERTIES \ COMPILE_FLAGS ${target_compile_flags} \ INSTALL_RPATH_USE_LINK_PATH TRUE \ -INSTALL_RPATH " (assoc-ref outputs "out") "/lib)\n"))) - #t)) +INSTALL_RPATH " (assoc-ref outputs "out") "/lib)\n"))))) (add-after 'build 'build-pip-package - (lambda* (#:key outputs #:allow-other-keys) + (lambda* (#:key outputs parallel-build? #:allow-other-keys) (setenv "LDFLAGS" (string-append "-Wl,-rpath=" (assoc-ref outputs "out") "/lib")) - (invoke "make" "tf_python_build_pip_package") - #t)) + (invoke "make" "-j" (if parallel-build? + (number->string (parallel-job-count)) + "1") + "tf_python_build_pip_package"))) (add-after 'build-pip-package 'install-python (lambda* (#:key inputs outputs #:allow-other-keys) (let ((out (assoc-ref outputs "out")) (wheel (car (find-files "../build/tf_python/dist/" "\\.whl$"))) (python-version (python-version - (assoc-ref inputs "python")))) + (assoc-ref inputs "python")))) (invoke "python" "-m" "pip" "install" wheel (string-append "--prefix=" out)) @@ -1983,8 +1961,7 @@ INSTALL_RPATH " (assoc-ref outputs "out") "/lib)\n"))) (string-append out "/lib/python" python-version "/site-packages/tensorflow/contrib/" - "seq2seq/python/ops/lib_beam_search_ops.so")) - #t)))))) + "seq2seq/python/ops/lib_beam_search_ops.so")))))))) (native-inputs `(("pkg-config" ,pkg-config) ("protobuf:native" ,protobuf-3.6) ; protoc @@ -2244,7 +2221,7 @@ advanced research.") (install-file file target-dir))) (find-files "." "\\.h$"))))))))) (inputs - `(("abseil-cpp" ,abseil-cpp) + `(("abseil-cpp" ,abseil-cpp-20200923.3) ("eigen" ,eigen-for-tensorflow-lite) ("flatbuffers" ,flatbuffers) ("python" ,python))) @@ -2552,24 +2529,31 @@ with image data, text data, and sequence data.") (delete-file "keras/backend/theano_backend.py") (delete-file "keras/backend/cntk_backend.py") (delete-file "tests/keras/backend/backend_test.py") - ;; FIXME: This doesn't work because Tensorflow is missing the ;; coder ops library. - (delete-file "tests/keras/test_callbacks.py") - #t)) + (delete-file "tests/keras/test_callbacks.py"))) (replace 'check - (lambda _ - ;; These tests attempt to download data files from the internet. - (delete-file "tests/integration_tests/test_datasets.py") - (delete-file "tests/integration_tests/imagenet_utils_test.py") - ;; Backport https://github.com/keras-team/keras/pull/12479. - (substitute* "tests/keras/engine/test_topology.py" - (("np.ones\\(\\(3, 2\\)\\)") - "1.")) - (invoke "python" "-m" "pytest" - ;; The following test fail only in the build container; - ;; skip it. - "-k" "not test_selu")))))) + (lambda* (#:key tests? #:allow-other-keys) + (when tests? + ;; These tests attempt to download data files from the internet. + (delete-file "tests/integration_tests/test_datasets.py") + (delete-file "tests/integration_tests/imagenet_utils_test.py") + ;; Backport https://github.com/keras-team/keras/pull/12479. + (substitute* "tests/keras/engine/test_topology.py" + (("np.ones\\(\\(3, 2\\)\\)") + "1.")) + (invoke "python" "-m" "pytest" "tests" + "-p" "no:pep8" + ;; FIXME: python-build-system lacks PARALLEL-TESTS? + "-n" (number->string (parallel-job-count)) + "-k" + (string-append + ;; The following test fails only in the build + ;; container; skip it. + "not test_selu " + ;; The following test was found flaky and removed in + ;; recent versions. + "and not test_stateful_metrics")))))))) (propagated-inputs `(("python-h5py" ,python-h5py) ("python-keras-applications" ,python-keras-applications) @@ -2596,7 +2580,6 @@ with image data, text data, and sequence data.") and capable of running on top of TensorFlow. It was developed with a focus on enabling fast experimentation. Use Keras if you need a deep learning library that: - @itemize @item Allows for easy and fast prototyping (through user friendliness, modularity, and extensibility). @@ -2836,13 +2819,10 @@ TensorFlow.js, PyTorch, and MediaPipe.") (lambda* (#:key inputs outputs tests? #:allow-other-keys) ;; Run the test suite following the instructions in ;; 'CONTRIBUTING.md'. XXX: Unfortunately this doesn't - ;; work, unless you set PYTHONPATH presumably. + ;; work, unless you set GUIX_PYTHONPATH presumably. (when tests? - (let ((python-site (site-packages inputs outputs))) - (setenv "PYTHONPATH" - (string-append python-site ":" - (getenv "PYTHONPATH"))) - (invoke "python" "test/run_test.py"))))) + (add-installed-pythonpath inputs outputs) + (invoke "python" "test/run_test.py")))) (add-after 'install 'remove-test-executables (lambda* (#:key inputs outputs #:allow-other-keys) ;; Remove test executables, but keep other executables @@ -2855,6 +2835,7 @@ TensorFlow.js, PyTorch, and MediaPipe.") ;; XXX: Tests attempt to download data such as ;; <https://raw.githubusercontent.com/pytorch/test-infra/master/stats/slow-tests.json>. + ;; We're also missing some Python modules, such as expecttest. #:tests? #f)) (native-inputs `(("cmake" ,cmake) @@ -2878,6 +2859,7 @@ TensorFlow.js, PyTorch, and MediaPipe.") ("zstd" ,zstd))) (propagated-inputs `(("python-astunparse" ,python-astunparse) + ("python-click" ,python-click) ("python-numpy" ,python-numpy) ("python-pyyaml" ,python-pyyaml) ("python-cffi" ,python-cffi) |