Commit | Line | Data |
---|---|---|
741115b6 | 1 | ;;; GNU Guix --- Functional package management for GNU |
0877b74f | 2 | ;;; Copyright © 2015, 2016, 2017, 2018, 2019, 2020 Ricardo Wurmus <rekado@elephly.net> |
d56d3ae7 | 3 | ;;; Copyright © 2016, 2020 Efraim Flashner <efraim@flashner.co.il> |
382550f0 | 4 | ;;; Copyright © 2016, 2017, 2020 Marius Bakke <mbakke@fastmail.com> |
be6eb2f1 | 5 | ;;; Copyright © 2016 Hartmut Goebel <h.goebel@crazy-compilers.com> |
d2a7cb46 | 6 | ;;; Copyright © 2018, 2019, 2020 Tobias Geerinckx-Rice <me@tobias.gr> |
3a354e10 | 7 | ;;; Copyright © 2018 Kei Kebreau <kkebreau@posteo.net> |
a9b34762 MM |
8 | ;;; Copyright © 2018 Mark Meyer <mark@ofosos.org> |
9 | ;;; Copyright © 2018 Ben Woodcroft <donttrustben@gmail.com> | |
2dab4188 | 10 | ;;; Copyright © 2018 Fis Trivial <ybbs.daans@hotmail.com> |
564cf93f | 11 | ;;; Copyright © 2018 Julien Lepiller <julien@lepiller.eu> |
df4c8434 | 12 | ;;; Copyright © 2018 Björn Höfling <bjoern.hoefling@bjoernhoefling.de> |
d60b064d | 13 | ;;; Copyright © 2019 Nicolas Goaziou <mail@nicolasgoaziou.fr> |
5dc04da4 | 14 | ;;; Copyright © 2019, 2020 Guillaume Le Vaillant <glv@posteo.net> |
5e42d197 | 15 | ;;; Copyright © 2019 Brett Gilio <brettg@gnu.org> |
d9e9a261 | 16 | ;;; Copyright © 2020 Konrad Hinsen <konrad.hinsen@fastmail.net> |
bcbd6340 | 17 | ;;; Copyright © 2020 Edouard Klein <edk@beaver-labs.com> |
741115b6 RW |
18 | ;;; |
19 | ;;; This file is part of GNU Guix. | |
20 | ;;; | |
21 | ;;; GNU Guix is free software; you can redistribute it and/or modify it | |
22 | ;;; under the terms of the GNU General Public License as published by | |
23 | ;;; the Free Software Foundation; either version 3 of the License, or (at | |
24 | ;;; your option) any later version. | |
25 | ;;; | |
26 | ;;; GNU Guix is distributed in the hope that it will be useful, but | |
27 | ;;; WITHOUT ANY WARRANTY; without even the implied warranty of | |
28 | ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
29 | ;;; GNU General Public License for more details. | |
30 | ;;; | |
31 | ;;; You should have received a copy of the GNU General Public License | |
32 | ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>. | |
33 | ||
34 | (define-module (gnu packages machine-learning) | |
35 | #:use-module ((guix licenses) #:prefix license:) | |
36 | #:use-module (guix packages) | |
37 | #:use-module (guix utils) | |
38 | #:use-module (guix download) | |
23aab4ab | 39 | #:use-module (guix svn-download) |
6e760872 | 40 | #:use-module (guix build-system asdf) |
c1670a81 | 41 | #:use-module (guix build-system cmake) |
741115b6 | 42 | #:use-module (guix build-system gnu) |
0a3063d6 | 43 | #:use-module (guix build-system ocaml) |
be6eb2f1 | 44 | #:use-module (guix build-system python) |
8406138b | 45 | #:use-module (guix build-system r) |
a9b34762 | 46 | #:use-module (guix git-download) |
71f80f54 | 47 | #:use-module (gnu packages) |
0dfeb285 | 48 | #:use-module (gnu packages adns) |
5a14e81e | 49 | #:use-module (gnu packages algebra) |
b9445d0b | 50 | #:use-module (gnu packages audio) |
23aab4ab | 51 | #:use-module (gnu packages autotools) |
b9445d0b | 52 | #:use-module (gnu packages base) |
99260014 | 53 | #:use-module (gnu packages bash) |
0931c609 | 54 | #:use-module (gnu packages boost) |
be6eb2f1 | 55 | #:use-module (gnu packages check) |
0931c609 | 56 | #:use-module (gnu packages compression) |
9e37e537 | 57 | #:use-module (gnu packages cran) |
4fa16c9a | 58 | #:use-module (gnu packages databases) |
23aab4ab | 59 | #:use-module (gnu packages dejagnu) |
0931c609 | 60 | #:use-module (gnu packages gcc) |
b9445d0b | 61 | #:use-module (gnu packages glib) |
f1765b57 | 62 | #:use-module (gnu packages graphviz) |
b9445d0b | 63 | #:use-module (gnu packages gstreamer) |
5f0ff6a9 | 64 | #:use-module (gnu packages image) |
b9445d0b | 65 | #:use-module (gnu packages linux) |
88f06fd0 | 66 | #:use-module (gnu packages lisp-xyz) |
0931c609 | 67 | #:use-module (gnu packages maths) |
112c2c01 | 68 | #:use-module (gnu packages mpi) |
0a3063d6 | 69 | #:use-module (gnu packages ocaml) |
3929f46c | 70 | #:use-module (gnu packages onc-rpc) |
791c11d6 | 71 | #:use-module (gnu packages perl) |
c1670a81 | 72 | #:use-module (gnu packages pkg-config) |
0dfeb285 | 73 | #:use-module (gnu packages protobuf) |
0931c609 | 74 | #:use-module (gnu packages python) |
ec1224a7 | 75 | #:use-module (gnu packages python-science) |
10451f6b | 76 | #:use-module (gnu packages python-web) |
44d10b1f | 77 | #:use-module (gnu packages python-xyz) |
c61557b1 | 78 | #:use-module (gnu packages rpc) |
4fa16c9a | 79 | #:use-module (gnu packages serialization) |
f1765b57 | 80 | #:use-module (gnu packages sphinx) |
c1670a81 | 81 | #:use-module (gnu packages statistics) |
4fa16c9a | 82 | #:use-module (gnu packages sqlite) |
c1670a81 | 83 | #:use-module (gnu packages swig) |
99260014 | 84 | #:use-module (gnu packages web) |
5f0ff6a9 | 85 | #:use-module (gnu packages xml) |
39bb4937 RW |
86 | #:use-module (gnu packages xorg) |
87 | #:use-module (ice-9 match)) | |
741115b6 | 88 | |
a9b34762 MM |
89 | (define-public fann |
90 | ;; The last release is >100 commits behind, so we package from git. | |
91 | (let ((commit "d71d54788bee56ba4cf7522801270152da5209d7")) | |
92 | (package | |
93 | (name "fann") | |
94 | (version (string-append "2.2.0-1." (string-take commit 8))) | |
95 | (source (origin | |
96 | (method git-fetch) | |
97 | (uri (git-reference | |
98 | (url "https://github.com/libfann/fann.git") | |
99 | (commit commit))) | |
100 | (file-name (string-append name "-" version "-checkout")) | |
101 | (sha256 | |
102 | (base32 | |
103 | "0ibwpfrjs6q2lijs8slxjgzb2llcl6rk3v2ski4r6215g5jjhg3x")))) | |
104 | (build-system cmake-build-system) | |
105 | (arguments | |
106 | `(#:phases | |
107 | (modify-phases %standard-phases | |
108 | (replace 'check | |
109 | (lambda* (#:key outputs #:allow-other-keys) | |
110 | (let* ((out (assoc-ref outputs "out"))) | |
111 | (with-directory-excursion (string-append (getcwd) "/tests") | |
112 | (invoke "./fann_tests")))))))) | |
113 | (home-page "http://leenissen.dk/fann/wp/") | |
114 | (synopsis "Fast Artificial Neural Network") | |
115 | (description | |
bd2bd80d MB |
116 | "FANN is a neural network library, which implements multilayer |
117 | artificial neural networks in C with support for both fully connected and | |
118 | sparsely connected networks.") | |
a9b34762 MM |
119 | (license license:lgpl2.1)))) |
120 | ||
741115b6 RW |
121 | (define-public libsvm |
122 | (package | |
123 | (name "libsvm") | |
2cffa2f2 | 124 | (version "3.23") |
741115b6 RW |
125 | (source |
126 | (origin | |
127 | (method url-fetch) | |
d1308c5e TGR |
128 | (uri (string-append "https://www.csie.ntu.edu.tw/~cjlin/libsvm/" |
129 | name "-" version ".tar.gz")) | |
741115b6 | 130 | (sha256 |
2cffa2f2 | 131 | (base32 "0jpaq0rr92x38p4nk3gjan79ip67m6p80anb28z1d8601miysyi5")))) |
741115b6 RW |
132 | (build-system gnu-build-system) |
133 | (arguments | |
2cffa2f2 | 134 | `(#:tests? #f ; no "check" target |
741115b6 RW |
135 | #:phases (modify-phases %standard-phases |
136 | (delete 'configure) | |
137 | (replace | |
d1308c5e | 138 | 'install ; no ‘install’ target |
741115b6 RW |
139 | (lambda* (#:key outputs #:allow-other-keys) |
140 | (let* ((out (assoc-ref outputs "out")) | |
141 | (bin (string-append out "/bin/"))) | |
142 | (mkdir-p bin) | |
143 | (for-each (lambda (file) | |
144 | (copy-file file (string-append bin file))) | |
145 | '("svm-train" | |
146 | "svm-predict" | |
147 | "svm-scale"))) | |
148 | #t))))) | |
62290cd4 | 149 | (home-page "https://www.csie.ntu.edu.tw/~cjlin/libsvm/") |
741115b6 RW |
150 | (synopsis "Library for Support Vector Machines") |
151 | (description | |
152 | "LIBSVM is a machine learning library for support vector | |
153 | classification, (C-SVC, nu-SVC), regression (epsilon-SVR, nu-SVR) and | |
154 | distribution estimation (one-class SVM). It supports multi-class | |
155 | classification.") | |
156 | (license license:bsd-3))) | |
71f80f54 RW |
157 | |
158 | (define-public python-libsvm | |
159 | (package (inherit libsvm) | |
160 | (name "python-libsvm") | |
161 | (build-system gnu-build-system) | |
162 | (arguments | |
2cffa2f2 | 163 | `(#:tests? #f ; no "check" target |
71f80f54 RW |
164 | #:make-flags '("-C" "python") |
165 | #:phases | |
166 | (modify-phases %standard-phases | |
167 | (delete 'configure) | |
168 | (replace | |
d1308c5e | 169 | 'install ; no ‘install’ target |
71f80f54 RW |
170 | (lambda* (#:key inputs outputs #:allow-other-keys) |
171 | (let ((site (string-append (assoc-ref outputs "out") | |
172 | "/lib/python" | |
173 | (string-take | |
174 | (string-take-right | |
175 | (assoc-ref inputs "python") 5) 3) | |
176 | "/site-packages/"))) | |
177 | (substitute* "python/svm.py" | |
178 | (("../libsvm.so.2") "libsvm.so.2")) | |
179 | (mkdir-p site) | |
180 | (for-each (lambda (file) | |
181 | (copy-file file (string-append site (basename file)))) | |
182 | (find-files "python" "\\.py")) | |
183 | (copy-file "libsvm.so.2" | |
184 | (string-append site "libsvm.so.2"))) | |
185 | #t))))) | |
186 | (inputs | |
187 | `(("python" ,python))) | |
188 | (synopsis "Python bindings of libSVM"))) | |
0931c609 | 189 | |
23aab4ab RW |
190 | (define-public ghmm |
191 | ;; The latest release candidate is several years and a couple of fixes have | |
192 | ;; been published since. This is why we download the sources from the SVN | |
193 | ;; repository. | |
194 | (let ((svn-revision 2341)) | |
195 | (package | |
196 | (name "ghmm") | |
197 | (version (string-append "0.9-rc3-0." (number->string svn-revision))) | |
198 | (source (origin | |
199 | (method svn-fetch) | |
200 | (uri (svn-reference | |
201 | (url "http://svn.code.sf.net/p/ghmm/code/trunk") | |
202 | (revision svn-revision))) | |
e3a69938 | 203 | (file-name (string-append name "-" version "-checkout")) |
23aab4ab RW |
204 | (sha256 |
205 | (base32 | |
206 | "0qbq1rqp94l530f043qzp8aw5lj7dng9wq0miffd7spd1ff638wq")))) | |
207 | (build-system gnu-build-system) | |
208 | (arguments | |
ced12a7b RW |
209 | `(#:imported-modules (,@%gnu-build-system-modules |
210 | (guix build python-build-system)) | |
3cb8cb66 MB |
211 | #:modules ((guix build python-build-system) |
212 | ,@%gnu-build-system-modules) | |
ced12a7b | 213 | #:phases |
23aab4ab RW |
214 | (modify-phases %standard-phases |
215 | (add-after 'unpack 'enter-dir | |
216 | (lambda _ (chdir "ghmm") #t)) | |
ced12a7b RW |
217 | (delete 'check) |
218 | (add-after 'install 'check | |
219 | (assoc-ref %standard-phases 'check)) | |
220 | (add-before 'check 'fix-PYTHONPATH | |
221 | (lambda* (#:key inputs outputs #:allow-other-keys) | |
9c2563a8 | 222 | (let ((python-version (python-version |
ced12a7b RW |
223 | (assoc-ref inputs "python")))) |
224 | (setenv "PYTHONPATH" | |
225 | (string-append (getenv "PYTHONPATH") | |
226 | ":" (assoc-ref outputs "out") | |
227 | "/lib/python" python-version | |
228 | "/site-packages"))) | |
23aab4ab RW |
229 | #t)) |
230 | (add-after 'enter-dir 'fix-runpath | |
231 | (lambda* (#:key outputs #:allow-other-keys) | |
232 | (substitute* "ghmmwrapper/setup.py" | |
233 | (("^(.*)extra_compile_args = \\[" line indent) | |
234 | (string-append indent | |
235 | "extra_link_args = [\"-Wl,-rpath=" | |
236 | (assoc-ref outputs "out") "/lib\"],\n" | |
237 | line | |
238 | "\"-Wl,-rpath=" | |
239 | (assoc-ref outputs "out") | |
240 | "/lib\", "))) | |
241 | #t)) | |
242 | (add-after 'enter-dir 'disable-broken-tests | |
243 | (lambda _ | |
244 | (substitute* "tests/Makefile.am" | |
245 | ;; GHMM_SILENT_TESTS is assumed to be a command. | |
246 | (("TESTS_ENVIRONMENT.*") "") | |
247 | ;; Do not build broken tests. | |
248 | (("chmm .*") "") | |
249 | (("read_fa .*") "") | |
250 | (("mcmc .*") "") | |
251 | (("label_higher_order_test.*$") | |
252 | "label_higher_order_test\n")) | |
253 | ||
254 | ;; These Python unittests are broken as there is no gato. | |
255 | ;; See https://sourceforge.net/p/ghmm/support-requests/3/ | |
256 | (substitute* "ghmmwrapper/ghmmunittests.py" | |
257 | (("^(.*)def (testNewXML|testMultipleTransitionClasses|testNewXML)" | |
258 | line indent) | |
259 | (string-append indent | |
260 | "@unittest.skip(\"Disabled by Guix\")\n" | |
261 | line))) | |
a491856f | 262 | #t))))) |
23aab4ab RW |
263 | (inputs |
264 | `(("python" ,python-2) ; only Python 2 is supported | |
265 | ("libxml2" ,libxml2))) | |
266 | (native-inputs | |
267 | `(("pkg-config" ,pkg-config) | |
268 | ("dejagnu" ,dejagnu) | |
269 | ("swig" ,swig) | |
270 | ("autoconf" ,autoconf) | |
271 | ("automake" ,automake) | |
272 | ("libtool" ,libtool))) | |
273 | (home-page "http://ghmm.org") | |
274 | (synopsis "Hidden Markov Model library") | |
275 | (description | |
276 | "The General Hidden Markov Model library (GHMM) is a C library with | |
277 | additional Python bindings implementing a wide range of types of @dfn{Hidden | |
d1e4ad1b | 278 | Markov Models} (HMM) and algorithms: discrete, continuous emissions, basic |
23aab4ab RW |
279 | training, HMM clustering, HMM mixtures.") |
280 | (license license:lgpl2.0+)))) | |
281 | ||
791c11d6 BW |
282 | (define-public mcl |
283 | (package | |
284 | (name "mcl") | |
285 | (version "14.137") | |
286 | (source (origin | |
287 | (method url-fetch) | |
288 | (uri (string-append | |
289 | "http://micans.org/mcl/src/mcl-" | |
290 | (string-replace-substring version "." "-") | |
291 | ".tar.gz")) | |
292 | (sha256 | |
293 | (base32 | |
294 | "15xlax3z31lsn62vlg94hkm75nm40q4679amnfg13jm8m2bnhy5m")))) | |
295 | (build-system gnu-build-system) | |
296 | (arguments | |
297 | `(#:configure-flags (list "--enable-blast"))) | |
298 | (inputs | |
299 | `(("perl" ,perl))) | |
300 | (home-page "http://micans.org/mcl/") | |
301 | (synopsis "Clustering algorithm for graphs") | |
302 | (description | |
303 | "The MCL algorithm is short for the @dfn{Markov Cluster Algorithm}, a | |
304 | fast and scalable unsupervised cluster algorithm for graphs (also known as | |
305 | networks) based on simulation of (stochastic) flow in graphs.") | |
306 | ;; In the LICENCE file and web page it says "The software is licensed | |
307 | ;; under the GNU General Public License, version 3.", but in several of | |
308 | ;; the source code files it suggests GPL3 or later. | |
309 | ;; http://listserver.ebi.ac.uk/pipermail/mcl-users/2016/000376.html | |
310 | (license license:gpl3))) | |
311 | ||
0a3063d6 BW |
312 | (define-public ocaml-mcl |
313 | (package | |
314 | (name "ocaml-mcl") | |
315 | (version "12-068oasis4") | |
316 | (source | |
317 | (origin | |
fb168a31 RW |
318 | (method git-fetch) |
319 | (uri (git-reference | |
320 | (url "https://github.com/fhcrc/mcl.git") | |
321 | (commit version))) | |
322 | (file-name (git-file-name name version)) | |
0a3063d6 BW |
323 | (sha256 |
324 | (base32 | |
fb168a31 | 325 | "0009dc3h2jp3qg5val452wngpqnbfyhbcxylghq0mrjqxx0jdq5p")))) |
0a3063d6 BW |
326 | (build-system ocaml-build-system) |
327 | (arguments | |
b24aaeec | 328 | `(#:phases |
0a3063d6 BW |
329 | (modify-phases %standard-phases |
330 | (add-before 'configure 'patch-paths | |
331 | (lambda _ | |
332 | (substitute* "configure" | |
b24aaeec | 333 | (("/bin/sh") (which "sh"))) |
0a3063d6 BW |
334 | (substitute* "setup.ml" |
335 | (("LDFLAGS=-fPIC") | |
b24aaeec RW |
336 | (string-append "LDFLAGS=-fPIC\"; \"SHELL=" (which "sh"))) |
337 | (("-std=c89") "-std=gnu99") | |
338 | ||
339 | ;; This is a mutable string, which is no longer supported. Use | |
340 | ;; a byte buffer instead. | |
341 | (("String.make \\(String.length s\\)") | |
342 | "Bytes.make (String.length s)") | |
343 | ||
344 | ;; These two belong together. | |
345 | (("OASISString.replace_chars") | |
346 | "Bytes.to_string (OASISString.replace_chars") | |
347 | ((" s;") | |
348 | " s);")) | |
349 | (substitute* "myocamlbuild.ml" | |
350 | (("std=c89") "std=gnu99")) | |
351 | ;; Since we build with a more recent OCaml, we have to use C99 or | |
352 | ;; later. This causes problems with the old C code. | |
353 | (substitute* "src/impala/matrix.c" | |
354 | (("restrict") "restrict_")) | |
0a3063d6 | 355 | #t))))) |
b24aaeec RW |
356 | (native-inputs |
357 | `(("ocamlbuild" ,ocamlbuild))) | |
0a3063d6 BW |
358 | (home-page "https://github.com/fhcrc/mcl") |
359 | (synopsis "OCaml wrappers around MCL") | |
360 | (description | |
361 | "This package provides OCaml bindings for the MCL graph clustering | |
362 | algorithm.") | |
363 | (license license:gpl3))) | |
364 | ||
0931c609 RW |
365 | (define-public randomjungle |
366 | (package | |
367 | (name "randomjungle") | |
368 | (version "2.1.0") | |
369 | (source | |
370 | (origin | |
371 | (method url-fetch) | |
372 | (uri (string-append | |
df4c8434 BH |
373 | "https://www.imbs.uni-luebeck.de/fileadmin/files/Software" |
374 | "/randomjungle/randomjungle-" version ".tar_.gz")) | |
1e92d311 | 375 | (patches (search-patches "randomjungle-disable-static-build.patch")) |
0931c609 RW |
376 | (sha256 |
377 | (base32 | |
378 | "12c8rf30cla71swx2mf4ww9mfd8jbdw5lnxd7dxhyw1ygrvg6y4w")))) | |
379 | (build-system gnu-build-system) | |
380 | (arguments | |
381 | `(#:configure-flags | |
1e92d311 MB |
382 | (list "--disable-static" |
383 | (string-append "--with-boost=" | |
0931c609 RW |
384 | (assoc-ref %build-inputs "boost"))) |
385 | #:phases | |
386 | (modify-phases %standard-phases | |
387 | (add-before | |
388 | 'configure 'set-CXXFLAGS | |
389 | (lambda _ | |
390 | (setenv "CXXFLAGS" "-fpermissive ") | |
391 | #t))))) | |
392 | (inputs | |
393 | `(("boost" ,boost) | |
394 | ("gsl" ,gsl) | |
395 | ("libxml2" ,libxml2) | |
396 | ("zlib" ,zlib))) | |
397 | (native-inputs | |
25e0037a EF |
398 | `(("gfortran" ,gfortran) |
399 | ("gfortran:lib" ,gfortran "lib"))) | |
47818201 RW |
400 | ;; Non-portable assembly instructions are used so building fails on |
401 | ;; platforms other than x86_64 or i686. | |
402 | (supported-systems '("x86_64-linux" "i686-linux")) | |
df4c8434 | 403 | (home-page "https://www.imbs.uni-luebeck.de/forschung/software/details.html#c224") |
0931c609 RW |
404 | (synopsis "Implementation of the Random Forests machine learning method") |
405 | (description | |
406 | "Random Jungle is an implementation of Random Forests. It is supposed to | |
407 | analyse high dimensional data. In genetics, it can be used for analysing big | |
408 | Genome Wide Association (GWA) data. Random Forests is a powerful machine | |
409 | learning method. Most interesting features are variable selection, missing | |
410 | value imputation, classifier creation, generalization error estimation and | |
411 | sample proximities between pairs of cases.") | |
412 | (license license:gpl3+))) | |
c1670a81 | 413 | |
7d4cab74 RW |
414 | (define-public openfst |
415 | (package | |
416 | (name "openfst") | |
5ed72097 | 417 | (version "1.7.2") |
7d4cab74 RW |
418 | (source (origin |
419 | (method url-fetch) | |
420 | (uri (string-append "http://www.openfst.org/twiki/pub/FST/" | |
421 | "FstDownload/openfst-" version ".tar.gz")) | |
422 | (sha256 | |
423 | (base32 | |
5ed72097 | 424 | "0fqgk8195kz21is09gwzwnrg7fr9526bi9mh4apyskapz27pbhr1")))) |
7d4cab74 RW |
425 | (build-system gnu-build-system) |
426 | (home-page "http://www.openfst.org") | |
427 | (synopsis "Library for weighted finite-state transducers") | |
428 | (description "OpenFst is a library for constructing, combining, | |
429 | optimizing, and searching weighted finite-state transducers (FSTs).") | |
430 | (license license:asl2.0))) | |
431 | ||
c1670a81 RW |
432 | (define-public shogun |
433 | (package | |
434 | (name "shogun") | |
5a14e81e | 435 | (version "6.1.3") |
c1670a81 RW |
436 | (source |
437 | (origin | |
438 | (method url-fetch) | |
439 | (uri (string-append | |
440 | "ftp://shogun-toolbox.org/shogun/releases/" | |
441 | (version-major+minor version) | |
442 | "/sources/shogun-" version ".tar.bz2")) | |
443 | (sha256 | |
444 | (base32 | |
5a14e81e | 445 | "1rn9skm3nw6hr7mr3lgp2gfqhi7ii0lyxck7qmqnf8avq349s5jp")) |
c1670a81 RW |
446 | (modules '((guix build utils) |
447 | (ice-9 rdelim))) | |
448 | (snippet | |
449 | '(begin | |
450 | ;; Remove non-free sources and files referencing them | |
451 | (for-each delete-file | |
452 | (find-files "src/shogun/classifier/svm/" | |
453 | "SVMLight\\.(cpp|h)")) | |
454 | (for-each delete-file | |
455 | (find-files "examples/undocumented/libshogun/" | |
456 | (string-append | |
457 | "(classifier_.*svmlight.*|" | |
458 | "evaluation_cross_validation_locked_comparison).cpp"))) | |
459 | ;; Remove non-free functions. | |
460 | (define (delete-ifdefs file) | |
461 | (with-atomic-file-replacement file | |
462 | (lambda (in out) | |
463 | (let loop ((line (read-line in 'concat)) | |
464 | (skipping? #f)) | |
465 | (if (eof-object? line) | |
466 | #t | |
467 | (let ((skip-next? | |
468 | (or (and skipping? | |
469 | (not (string-prefix? | |
470 | "#endif //USE_SVMLIGHT" line))) | |
471 | (string-prefix? | |
472 | "#ifdef USE_SVMLIGHT" line)))) | |
473 | (when (or (not skipping?) | |
474 | (and skipping? (not skip-next?))) | |
475 | (display line out)) | |
476 | (loop (read-line in 'concat) skip-next?))))))) | |
5a14e81e KK |
477 | (for-each delete-ifdefs |
478 | (append | |
479 | (find-files "src/shogun/classifier/mkl" | |
480 | "^MKLClassification\\.cpp") | |
481 | (find-files "src/shogun/classifier/svm" | |
482 | "^SVMLightOneClass\\.(cpp|h)") | |
483 | (find-files "src/shogun/multiclass" | |
484 | "^ScatterSVM\\.(cpp|h)") | |
485 | (find-files "src/shogun/kernel/" | |
486 | "^(Kernel|CombinedKernel|ProductKernel)\\.(cpp|h)") | |
487 | (find-files "src/shogun/regression/svr" | |
488 | "^(MKLRegression|SVRLight)\\.(cpp|h)") | |
489 | (find-files "src/shogun/transfer/domain_adaptation" | |
c0d7c124 | 490 | "^DomainAdaptationSVM\\.(cpp|h)"))) |
6cbee49d | 491 | #t)))) |
c1670a81 RW |
492 | (build-system cmake-build-system) |
493 | (arguments | |
494 | '(#:tests? #f ;no check target | |
495 | #:phases | |
dc1d3cde KK |
496 | (modify-phases %standard-phases |
497 | (add-after 'unpack 'delete-broken-symlinks | |
498 | (lambda _ | |
499 | (for-each delete-file '("applications/arts/data" | |
500 | "applications/asp/data" | |
501 | "applications/easysvm/data" | |
502 | "applications/msplicer/data" | |
503 | "applications/ocr/data" | |
5a14e81e KK |
504 | "examples/meta/data" |
505 | "examples/undocumented/data")) | |
dc1d3cde KK |
506 | #t)) |
507 | (add-after 'unpack 'change-R-target-path | |
508 | (lambda* (#:key outputs #:allow-other-keys) | |
5a14e81e KK |
509 | (substitute* '("src/interfaces/r/CMakeLists.txt" |
510 | "examples/meta/r/CMakeLists.txt") | |
dc1d3cde KK |
511 | (("\\$\\{R_COMPONENT_LIB_PATH\\}") |
512 | (string-append (assoc-ref outputs "out") | |
513 | "/lib/R/library/"))) | |
514 | #t)) | |
515 | (add-after 'unpack 'fix-octave-modules | |
516 | (lambda* (#:key outputs #:allow-other-keys) | |
5a14e81e | 517 | (substitute* "src/interfaces/octave/CMakeLists.txt" |
dc1d3cde | 518 | (("^include_directories\\(\\$\\{OCTAVE_INCLUDE_DIRS\\}") |
5a14e81e KK |
519 | "include_directories(${OCTAVE_INCLUDE_DIRS} ${OCTAVE_INCLUDE_DIRS}/octave") |
520 | ;; change target directory | |
dc1d3cde KK |
521 | (("\\$\\{OCTAVE_OCT_LOCAL_API_FILE_DIR\\}") |
522 | (string-append (assoc-ref outputs "out") | |
523 | "/share/octave/packages"))) | |
5a14e81e KK |
524 | (substitute* '("src/interfaces/octave/swig_typemaps.i" |
525 | "src/interfaces/octave/sg_print_functions.cpp") | |
526 | ;; "octave/config.h" and "octave/oct-obj.h" deprecated in Octave. | |
527 | (("octave/config\\.h") "octave/octave-config.h") | |
528 | (("octave/oct-obj.h") "octave/ovl.h")) | |
dc1d3cde | 529 | #t)) |
5a14e81e KK |
530 | (add-after 'unpack 'move-rxcpp |
531 | (lambda* (#:key inputs #:allow-other-keys) | |
532 | (let ((rxcpp-dir "shogun/third-party/rxcpp")) | |
533 | (mkdir-p rxcpp-dir) | |
534 | (install-file (assoc-ref inputs "rxcpp") rxcpp-dir) | |
535 | #t))) | |
dc1d3cde | 536 | (add-before 'build 'set-HOME |
c1670a81 | 537 | ;; $HOME needs to be set at some point during the build phase |
dc1d3cde | 538 | (lambda _ (setenv "HOME" "/tmp") #t))) |
c1670a81 RW |
539 | #:configure-flags |
540 | (list "-DCMAKE_BUILD_WITH_INSTALL_RPATH=TRUE" | |
541 | "-DUSE_SVMLIGHT=OFF" ;disable proprietary SVMLIGHT | |
5a14e81e KK |
542 | "-DBUILD_META_EXAMPLES=OFF" ;requires unpackaged ctags |
543 | ;;"-DINTERFACE_JAVA=ON" ;requires unpackaged jblas | |
544 | ;;"-DINTERFACE_RUBY=ON" ;requires unpackaged ruby-narray | |
545 | ;;"-DINTERFACE_PERL=ON" ;"FindPerlLibs" does not exist | |
546 | ;;"-DINTERFACE_LUA=ON" ;fails because lua doesn't build pkgconfig file | |
547 | "-DINTERFACE_OCTAVE=ON" | |
548 | "-DINTERFACE_PYTHON=ON" | |
549 | "-DINTERFACE_R=ON"))) | |
c1670a81 RW |
550 | (inputs |
551 | `(("python" ,python) | |
552 | ("numpy" ,python-numpy) | |
2d7c4ae3 | 553 | ("r-minimal" ,r-minimal) |
5537603f | 554 | ("octave" ,octave-cli) |
c1670a81 | 555 | ("swig" ,swig) |
5a14e81e | 556 | ("eigen" ,eigen) |
c1670a81 RW |
557 | ("hdf5" ,hdf5) |
558 | ("atlas" ,atlas) | |
559 | ("arpack" ,arpack-ng) | |
560 | ("lapack" ,lapack) | |
561 | ("glpk" ,glpk) | |
562 | ("libxml2" ,libxml2) | |
563 | ("lzo" ,lzo) | |
564 | ("zlib" ,zlib))) | |
565 | (native-inputs | |
5a14e81e KK |
566 | `(("pkg-config" ,pkg-config) |
567 | ("rxcpp" ,rxcpp))) | |
6b5b656f RW |
568 | ;; Non-portable SSE instructions are used so building fails on platforms |
569 | ;; other than x86_64. | |
570 | (supported-systems '("x86_64-linux")) | |
df10a64e | 571 | (home-page "https://shogun-toolbox.org/") |
c1670a81 RW |
572 | (synopsis "Machine learning toolbox") |
573 | (description | |
574 | "The Shogun Machine learning toolbox provides a wide range of unified and | |
cc24c4cb VC |
575 | efficient Machine Learning (ML) methods. The toolbox seamlessly |
576 | combines multiple data representations, algorithm classes, and general purpose | |
c1670a81 RW |
577 | tools. This enables both rapid prototyping of data pipelines and extensibility |
578 | in terms of new algorithms.") | |
579 | (license license:gpl3+))) | |
8406138b | 580 | |
3a354e10 KK |
581 | (define-public rxcpp |
582 | (package | |
583 | (name "rxcpp") | |
e91a0bff | 584 | (version "4.1.0") |
3a354e10 KK |
585 | (source |
586 | (origin | |
5daafe0b TGR |
587 | (method git-fetch) |
588 | (uri (git-reference | |
589 | (url "https://github.com/ReactiveX/RxCpp.git") | |
590 | (commit (string-append "v" version)))) | |
3a354e10 | 591 | (sha256 |
5daafe0b TGR |
592 | (base32 "1rdpa3jlc181jd08nk437aar085h28i45s6nzrv65apb3xyyz0ij")) |
593 | (file-name (git-file-name name version)))) | |
3a354e10 KK |
594 | (build-system cmake-build-system) |
595 | (arguments | |
596 | `(#:phases | |
597 | (modify-phases %standard-phases | |
598 | (add-after 'unpack 'remove-werror | |
599 | (lambda _ | |
600 | (substitute* (find-files ".") | |
601 | (("-Werror") "")) | |
602 | #t)) | |
603 | (replace 'check | |
604 | (lambda _ | |
605 | (invoke "ctest")))))) | |
606 | (native-inputs | |
607 | `(("catch" ,catch-framework))) | |
608 | (home-page "http://reactivex.io/") | |
609 | (synopsis "Reactive Extensions for C++") | |
610 | (description | |
611 | "The Reactive Extensions for C++ (RxCpp) is a library of algorithms for | |
612 | values-distributed-in-time. ReactiveX is a library for composing asynchronous | |
613 | and event-based programs by using observable sequences. | |
614 | ||
615 | It extends the observer pattern to support sequences of data and/or events and | |
616 | adds operators that allow you to compose sequences together declaratively while | |
617 | abstracting away concerns about things like low-level threading, | |
618 | synchronization, thread-safety, concurrent data structures, and non-blocking | |
619 | I/O.") | |
620 | (license license:asl2.0))) | |
621 | ||
8406138b RW |
622 | (define-public r-adaptivesparsity |
623 | (package | |
624 | (name "r-adaptivesparsity") | |
c0608f81 | 625 | (version "1.6") |
8406138b RW |
626 | (source (origin |
627 | (method url-fetch) | |
628 | (uri (cran-uri "AdaptiveSparsity" version)) | |
629 | (sha256 | |
630 | (base32 | |
c0608f81 | 631 | "0imr5m8mll9j6n4icsv6z9rl5kbnwsp9wvzrg7n90nnmcxq2cz91")))) |
8406138b RW |
632 | (properties |
633 | `((upstream-name . "AdaptiveSparsity"))) | |
634 | (build-system r-build-system) | |
635 | (arguments | |
636 | `(#:phases | |
637 | (modify-phases %standard-phases | |
638 | (add-after 'unpack 'link-against-armadillo | |
639 | (lambda _ | |
640 | (substitute* "src/Makevars" | |
641 | (("PKG_LIBS=" prefix) | |
642 | (string-append prefix "-larmadillo")))))))) | |
643 | (propagated-inputs | |
c0608f81 RW |
644 | `(("r-mass" ,r-mass) |
645 | ("r-matrix" ,r-matrix) | |
646 | ("r-rcpp" ,r-rcpp) | |
8406138b | 647 | ("r-rcpparmadillo" ,r-rcpparmadillo))) |
60e36bff LC |
648 | (inputs |
649 | `(("armadillo" ,armadillo))) | |
e9960d8c | 650 | (home-page "https://cran.r-project.org/web/packages/AdaptiveSparsity") |
8406138b RW |
651 | (synopsis "Adaptive sparsity models") |
652 | (description | |
653 | "This package implements the Figueiredo machine learning algorithm for | |
654 | adaptive sparsity and the Wong algorithm for adaptively sparse gaussian | |
655 | geometric models.") | |
656 | (license license:lgpl3+))) | |
e4785eb8 | 657 | |
39bb4937 RW |
658 | (define-public gemmlowp-for-tensorflow |
659 | ;; The commit hash is taken from "tensorflow/workspace.bzl". | |
660 | (let ((commit "38ebac7b059e84692f53e5938f97a9943c120d98") | |
661 | (revision "2")) | |
662 | (package | |
663 | (name "gemmlowp") | |
664 | (version (git-version "0" revision commit)) | |
665 | (source (origin | |
666 | (method url-fetch) | |
667 | (uri (string-append "https://mirror.bazel.build/" | |
668 | "github.com/google/gemmlowp/archive/" | |
669 | commit ".zip")) | |
670 | (file-name (string-append "gemmlowp-" version ".zip")) | |
671 | (sha256 | |
672 | (base32 | |
673 | "0n56s2g8hrssm4w8qj1v58gfm56a04n9v992ixkmvk6zjiralzxq")))) | |
674 | (build-system cmake-build-system) | |
675 | (arguments | |
676 | `(#:configure-flags | |
677 | (list ,@(match (%current-system) | |
678 | ((or "x86_64-linux" "i686-linux") | |
a32e3b90 | 679 | '("-DCMAKE_CXX_FLAGS=-msse2")) |
39bb4937 RW |
680 | (_ '()))) |
681 | #:phases | |
682 | (modify-phases %standard-phases | |
683 | ;; This directory contains the CMakeLists.txt. | |
684 | (add-after 'unpack 'chdir | |
685 | (lambda _ (chdir "contrib") #t)) | |
686 | ;; There is no install target | |
687 | (replace 'install | |
688 | (lambda* (#:key outputs #:allow-other-keys) | |
689 | (let* ((out (assoc-ref outputs "out")) | |
690 | (lib (string-append out "/lib/")) | |
691 | (inc (string-append out "/include/"))) | |
692 | (install-file "../build/libeight_bit_int_gemm.so" lib) | |
693 | (for-each (lambda (dir) | |
694 | (let ((target (string-append inc "/" dir))) | |
695 | (mkdir-p target) | |
696 | (for-each (lambda (h) | |
697 | (install-file h target)) | |
698 | (find-files (string-append "../" dir) | |
699 | "\\.h$")))) | |
700 | '("meta" "profiling" "public" "fixedpoint" | |
701 | "eight_bit_int_gemm" "internal")) | |
702 | #t)))))) | |
703 | (native-inputs | |
704 | `(("unzip" ,unzip))) | |
705 | (home-page "https://github.com/google/gemmlowp") | |
706 | (synopsis "Small self-contained low-precision GEMM library") | |
707 | (description | |
708 | "This is a small self-contained low-precision @dfn{general matrix | |
709 | multiplication} (GEMM) library. It is not a full linear algebra library. | |
710 | Low-precision means that the input and output matrix entries are integers on | |
711 | at most 8 bits. To avoid overflow, results are internally accumulated on more | |
712 | than 8 bits, and at the end only some significant 8 bits are kept.") | |
713 | (license license:asl2.0)))) | |
f05c7eb4 | 714 | |
5f0ff6a9 MB |
715 | (define-public dlib |
716 | (package | |
717 | (name "dlib") | |
d2a7cb46 | 718 | (version "19.20") |
5f0ff6a9 MB |
719 | (source (origin |
720 | (method url-fetch) | |
721 | (uri (string-append | |
722 | "http://dlib.net/files/dlib-" version ".tar.bz2")) | |
723 | (sha256 | |
724 | (base32 | |
d2a7cb46 | 725 | "139jyi19qz37wwmmy48gil9d1kkh2r3w3bwdzabha6ayxmba96nz")) |
5f0ff6a9 MB |
726 | (modules '((guix build utils))) |
727 | (snippet | |
728 | '(begin | |
729 | ;; Delete ~13MB of bundled dependencies. | |
730 | (delete-file-recursively "dlib/external") | |
0ef7ea66 MB |
731 | (delete-file-recursively "docs/dlib/external") |
732 | #t)))) | |
5f0ff6a9 MB |
733 | (build-system cmake-build-system) |
734 | (arguments | |
677bc34d | 735 | `(#:phases |
5f0ff6a9 MB |
736 | (modify-phases %standard-phases |
737 | (add-after 'unpack 'disable-asserts | |
738 | (lambda _ | |
739 | ;; config.h recommends explicitly enabling or disabling asserts | |
740 | ;; when building as a shared library. By default neither is set. | |
741 | (substitute* "dlib/config.h" | |
742 | (("^//#define DLIB_DISABLE_ASSERTS") "#define DLIB_DISABLE_ASSERTS")) | |
743 | #t)) | |
4fba38db MB |
744 | (add-after 'disable-asserts 'disable-failing-tests |
745 | (lambda _ | |
746 | ;; One test times out on MIPS, so we need to disable it. | |
0ef7ea66 | 747 | ;; Others are flaky on some platforms. |
4fba38db MB |
748 | (let* ((system ,(or (%current-target-system) |
749 | (%current-system))) | |
750 | (disabled-tests (cond | |
751 | ((string-prefix? "mips64" system) | |
752 | '("object_detector" ; timeout | |
753 | "data_io")) | |
754 | ((string-prefix? "armhf" system) | |
a343c461 | 755 | '("learning_to_track")) |
4fba38db | 756 | ((string-prefix? "i686" system) |
0ef7ea66 | 757 | '("optimization")) |
4fba38db | 758 | (else '())))) |
4fba38db MB |
759 | (for-each |
760 | (lambda (test) | |
761 | (substitute* "dlib/test/makefile" | |
0ef7ea66 MB |
762 | (((string-append "SRC \\+= " test "\\.cpp")) ""))) |
763 | disabled-tests) | |
764 | #t))) | |
5f0ff6a9 MB |
765 | (replace 'check |
766 | (lambda _ | |
767 | ;; No test target, so we build and run the unit tests here. | |
8eaf53e3 | 768 | (let ((test-dir (string-append "../dlib-" ,version "/dlib/test"))) |
5f0ff6a9 | 769 | (with-directory-excursion test-dir |
8448e6bf TGR |
770 | (invoke "make" "-j" (number->string (parallel-job-count))) |
771 | (invoke "./dtest" "--runall")) | |
772 | #t))) | |
5f0ff6a9 MB |
773 | (add-after 'install 'delete-static-library |
774 | (lambda* (#:key outputs #:allow-other-keys) | |
0ef7ea66 MB |
775 | (delete-file (string-append (assoc-ref outputs "out") |
776 | "/lib/libdlib.a")) | |
777 | #t))))) | |
5f0ff6a9 | 778 | (native-inputs |
3929f46c TGR |
779 | `(("pkg-config" ,pkg-config) |
780 | ;; For tests. | |
781 | ("libnsl" ,libnsl))) | |
5f0ff6a9 | 782 | (inputs |
f40841e9 | 783 | `(("giflib" ,giflib) |
4fba38db | 784 | ("lapack" ,lapack) |
4bd428a7 | 785 | ("libjpeg" ,libjpeg-turbo) |
5f0ff6a9 MB |
786 | ("libpng" ,libpng) |
787 | ("libx11" ,libx11) | |
788 | ("openblas" ,openblas) | |
789 | ("zlib" ,zlib))) | |
790 | (synopsis | |
791 | "Toolkit for making machine learning and data analysis applications in C++") | |
792 | (description | |
793 | "Dlib is a modern C++ toolkit containing machine learning algorithms and | |
794 | tools. It is used in both industry and academia in a wide range of domains | |
795 | including robotics, embedded devices, mobile phones, and large high performance | |
796 | computing environments.") | |
797 | (home-page "http://dlib.net") | |
798 | (license license:boost1.0))) | |
be6eb2f1 RW |
799 | |
800 | (define-public python-scikit-learn | |
801 | (package | |
802 | (name "python-scikit-learn") | |
83a483aa | 803 | (version "0.22.1") |
be6eb2f1 RW |
804 | (source |
805 | (origin | |
4a89bdd1 RW |
806 | (method git-fetch) |
807 | (uri (git-reference | |
808 | (url "https://github.com/scikit-learn/scikit-learn.git") | |
809 | (commit version))) | |
810 | (file-name (git-file-name name version)) | |
be6eb2f1 RW |
811 | (sha256 |
812 | (base32 | |
83a483aa | 813 | "1xqxv210gsmjw094vc5ghq2y9lmm74qkk22pq6flcjzj51b86jxf")))) |
be6eb2f1 RW |
814 | (build-system python-build-system) |
815 | (arguments | |
816 | `(#:phases | |
817 | (modify-phases %standard-phases | |
4a89bdd1 RW |
818 | (add-after 'build 'build-ext |
819 | (lambda _ (invoke "python" "setup.py" "build_ext" "--inplace") #t)) | |
820 | (replace 'check | |
821 | (lambda _ | |
822 | ;; Restrict OpenBLAS threads to prevent segfaults while testing! | |
823 | (setenv "OPENBLAS_NUM_THREADS" "1") | |
7ff3f3d2 MB |
824 | |
825 | ;; Some tests require write access to $HOME. | |
826 | (setenv "HOME" "/tmp") | |
827 | ||
828 | (invoke "pytest" "sklearn" "-m" "not network"))) | |
71804546 BL |
829 | (add-before 'reset-gzip-timestamps 'make-files-writable |
830 | (lambda* (#:key outputs #:allow-other-keys) | |
831 | ;; Make sure .gz files are writable so that the | |
832 | ;; 'reset-gzip-timestamps' phase can do its work. | |
833 | (let ((out (assoc-ref outputs "out"))) | |
834 | (for-each make-file-writable | |
835 | (find-files out "\\.gz$")) | |
836 | #t)))))) | |
be6eb2f1 RW |
837 | (inputs |
838 | `(("openblas" ,openblas))) | |
839 | (native-inputs | |
d9e9a261 | 840 | `(("python-pytest" ,python-pytest) |
4a89bdd1 | 841 | ("python-pandas" ,python-pandas) ;for tests |
be6eb2f1 RW |
842 | ("python-cython" ,python-cython))) |
843 | (propagated-inputs | |
844 | `(("python-numpy" ,python-numpy) | |
d9e9a261 KH |
845 | ("python-scipy" ,python-scipy) |
846 | ("python-joblib" ,python-joblib))) | |
e51b34bb | 847 | (home-page "https://scikit-learn.org/") |
be6eb2f1 RW |
848 | (synopsis "Machine Learning in Python") |
849 | (description | |
4a89bdd1 RW |
850 | "Scikit-learn provides simple and efficient tools for data mining and |
851 | data analysis.") | |
382550f0 | 852 | (properties `((python2-variant . ,(delay python2-scikit-learn)))) |
be6eb2f1 RW |
853 | (license license:bsd-3))) |
854 | ||
382550f0 MB |
855 | ;; scikit-learn 0.22 and later only supports Python 3, so we stick with |
856 | ;; an older version here. | |
be6eb2f1 | 857 | (define-public python2-scikit-learn |
382550f0 MB |
858 | (let ((base (package-with-python2 (strip-python2-variant python-scikit-learn)))) |
859 | (package | |
860 | (inherit base) | |
861 | (version "0.20.4") | |
862 | (source (origin | |
863 | (method git-fetch) | |
864 | (uri (git-reference | |
865 | (url "https://github.com/scikit-learn/scikit-learn.git") | |
866 | (commit version))) | |
867 | (file-name (git-file-name "python-scikit-learn" version)) | |
868 | (sha256 | |
869 | (base32 | |
870 | "08zbzi8yx5wdlxfx9jap61vg1malc9ajf576w7a0liv6jvvrxlpj"))))))) | |
2dab4188 | 871 | |
639ae3f2 RJ |
872 | (define-public python-scikit-rebate |
873 | (package | |
874 | (name "python-scikit-rebate") | |
875 | (version "0.6") | |
876 | (source (origin | |
877 | (method url-fetch) | |
878 | (uri (pypi-uri "skrebate" version)) | |
879 | (sha256 | |
880 | (base32 | |
881 | "1h7qs9gjxpzqabzhb8rmpv3jpmi5iq41kqdibg48299h94iikiw7")))) | |
882 | (build-system python-build-system) | |
883 | ;; Pandas is only needed to run the tests. | |
884 | (native-inputs | |
885 | `(("python-pandas" ,python-pandas))) | |
886 | (propagated-inputs | |
887 | `(("python-numpy" ,python-numpy) | |
888 | ("python-scipy" ,python-scipy) | |
889 | ("python-scikit-learn" ,python-scikit-learn) | |
890 | ("python-joblib" ,python-joblib))) | |
891 | (home-page "https://epistasislab.github.io/scikit-rebate/") | |
892 | (synopsis "Relief-based feature selection algorithms for Python") | |
893 | (description "Scikit-rebate is a scikit-learn-compatible Python | |
894 | implementation of ReBATE, a suite of Relief-based feature selection algorithms | |
895 | for Machine Learning. These algorithms excel at identifying features that are | |
896 | predictive of the outcome in supervised learning problems, and are especially | |
897 | good at identifying feature interactions that are normally overlooked by | |
898 | standard feature selection algorithms.") | |
899 | (license license:expat))) | |
900 | ||
2dab4188 FT |
901 | (define-public python-autograd |
902 | (let* ((commit "442205dfefe407beffb33550846434baa90c4de7") | |
903 | (revision "0") | |
904 | (version (git-version "0.0.0" revision commit))) | |
905 | (package | |
906 | (name "python-autograd") | |
907 | (home-page "https://github.com/HIPS/autograd") | |
908 | (source (origin | |
909 | (method git-fetch) | |
910 | (uri (git-reference | |
911 | (url home-page) | |
912 | (commit commit))) | |
913 | (sha256 | |
914 | (base32 | |
915 | "189sv2xb0mwnjawa9z7mrgdglc1miaq93pnck26r28fi1jdwg0z4")) | |
916 | (file-name (git-file-name name version)))) | |
917 | (version version) | |
918 | (build-system python-build-system) | |
919 | (native-inputs | |
920 | `(("python-nose" ,python-nose) | |
921 | ("python-pytest" ,python-pytest))) | |
922 | (propagated-inputs | |
923 | `(("python-future" ,python-future) | |
924 | ("python-numpy" ,python-numpy))) | |
925 | (arguments | |
926 | `(#:phases (modify-phases %standard-phases | |
927 | (replace 'check | |
928 | (lambda _ | |
929 | (invoke "py.test" "-v")))))) | |
930 | (synopsis "Efficiently computes derivatives of NumPy code") | |
931 | (description "Autograd can automatically differentiate native Python and | |
932 | NumPy code. It can handle a large subset of Python's features, including loops, | |
933 | ifs, recursion and closures, and it can even take derivatives of derivatives | |
934 | of derivatives. It supports reverse-mode differentiation | |
935 | (a.k.a. backpropagation), which means it can efficiently take gradients of | |
936 | scalar-valued functions with respect to array-valued arguments, as well as | |
937 | forward-mode differentiation, and the two can be composed arbitrarily. The | |
938 | main intended application of Autograd is gradient-based optimization.") | |
939 | (license license:expat)))) | |
940 | ||
941 | (define-public python2-autograd | |
942 | (package-with-python2 python-autograd)) | |
112c2c01 FT |
943 | |
944 | (define-public lightgbm | |
945 | (package | |
946 | (name "lightgbm") | |
947 | (version "2.0.12") | |
948 | (source (origin | |
949 | (method url-fetch) | |
950 | (uri (string-append | |
951 | "https://github.com/Microsoft/LightGBM/archive/v" | |
952 | version ".tar.gz")) | |
953 | (sha256 | |
954 | (base32 | |
955 | "132zf0yk0545mg72hyzxm102g3hpb6ixx9hnf8zd2k55gas6cjj1")) | |
956 | (file-name (string-append name "-" version ".tar.gz")))) | |
957 | (native-inputs | |
958 | `(("python-pytest" ,python-pytest) | |
959 | ("python-nose" ,python-nose))) | |
960 | (inputs | |
961 | `(("openmpi" ,openmpi))) | |
962 | (propagated-inputs | |
963 | `(("python-numpy" ,python-numpy) | |
964 | ("python-scipy" ,python-scipy))) | |
965 | (arguments | |
966 | `(#:configure-flags | |
967 | '("-DUSE_MPI=ON") | |
968 | #:phases | |
969 | (modify-phases %standard-phases | |
970 | (replace 'check | |
971 | (lambda* (#:key outputs #:allow-other-keys) | |
972 | (with-directory-excursion ,(string-append "../LightGBM-" version) | |
973 | (invoke "pytest" "tests/c_api_test/test_.py"))))))) | |
974 | (build-system cmake-build-system) | |
975 | (home-page "https://github.com/Microsoft/LightGBM") | |
976 | (synopsis "Gradient boosting framework based on decision tree algorithms") | |
977 | (description "LightGBM is a gradient boosting framework that uses tree | |
978 | based learning algorithms. It is designed to be distributed and efficient with | |
979 | the following advantages: | |
980 | ||
981 | @itemize | |
982 | @item Faster training speed and higher efficiency | |
983 | @item Lower memory usage | |
984 | @item Better accuracy | |
985 | @item Parallel and GPU learning supported (not enabled in this package) | |
986 | @item Capable of handling large-scale data | |
987 | @end itemize\n") | |
988 | (license license:expat))) | |
a8fb82a8 FT |
989 | |
990 | (define-public vowpal-wabbit | |
991 | ;; Language bindings not included. | |
992 | (package | |
993 | (name "vowpal-wabbit") | |
994 | (version "8.5.0") | |
995 | (source (origin | |
4eb40497 EF |
996 | (method git-fetch) |
997 | (uri (git-reference | |
998 | (url "https://github.com/JohnLangford/vowpal_wabbit") | |
999 | (commit version))) | |
a8fb82a8 FT |
1000 | (sha256 |
1001 | (base32 | |
4eb40497 EF |
1002 | "04bwzk6ifgnz3fmzid8b7avxf9n5pnx9xcjm61nkjng1vv0bpj8x")) |
1003 | (file-name (git-file-name name version)))) | |
a8fb82a8 FT |
1004 | (inputs |
1005 | `(("boost" ,boost) | |
1006 | ("zlib" ,zlib))) | |
1007 | (arguments | |
1008 | `(#:configure-flags | |
1009 | (list (string-append "--with-boost=" | |
4eb40497 EF |
1010 | (assoc-ref %build-inputs "boost"))) |
1011 | #:phases | |
1012 | (modify-phases %standard-phases | |
1013 | (add-after 'unpack 'make-files-writable | |
1014 | (lambda _ | |
1015 | (for-each make-file-writable (find-files "." ".*")) #t))))) | |
a8fb82a8 FT |
1016 | (build-system gnu-build-system) |
1017 | (home-page "https://github.com/JohnLangford/vowpal_wabbit") | |
1018 | (synopsis "Fast machine learning library for online learning") | |
1019 | (description "Vowpal Wabbit is a machine learning system with techniques | |
1020 | such as online, hashing, allreduce, reductions, learning2search, active, and | |
1021 | interactive learning.") | |
1022 | (license license:bsd-3))) | |
915c6bf6 LC |
1023 | |
1024 | (define-public python2-fastlmm | |
1025 | (package | |
1026 | (name "python2-fastlmm") | |
1027 | (version "0.2.21") | |
1028 | (source | |
1029 | (origin | |
1030 | (method url-fetch) | |
1031 | (uri (pypi-uri "fastlmm" version ".zip")) | |
1032 | (sha256 | |
1033 | (base32 | |
1034 | "1q8c34rpmwkfy3r4d5172pzdkpfryj561897z9r3x22gq7813x1m")))) | |
1035 | (build-system python-build-system) | |
1036 | (arguments | |
237ee6f2 RW |
1037 | `(#:tests? #f ; some test files are missing |
1038 | #:python ,python-2)) ; only Python 2.7 is supported | |
915c6bf6 LC |
1039 | (propagated-inputs |
1040 | `(("python2-numpy" ,python2-numpy) | |
1041 | ("python2-scipy" ,python2-scipy) | |
1042 | ("python2-matplotlib" ,python2-matplotlib) | |
1043 | ("python2-pandas" ,python2-pandas) | |
1044 | ("python2-scikit-learn" ,python2-scikit-learn) | |
1045 | ("python2-pysnptools" ,python2-pysnptools))) | |
1046 | (native-inputs | |
1047 | `(("unzip" ,unzip) | |
1048 | ("python2-cython" ,python2-cython) | |
1049 | ("python2-mock" ,python2-mock) | |
1050 | ("python2-nose" ,python2-nose))) | |
1051 | (home-page "http://research.microsoft.com/en-us/um/redmond/projects/mscompbio/fastlmm/") | |
1052 | (synopsis "Perform genome-wide association studies on large data sets") | |
1053 | (description | |
1054 | "FaST-LMM, which stands for Factored Spectrally Transformed Linear Mixed | |
1055 | Models, is a program for performing both single-SNP and SNP-set genome-wide | |
1056 | association studies (GWAS) on extremely large data sets.") | |
1057 | (license license:asl2.0))) | |
b9445d0b RW |
1058 | |
1059 | ;; There have been no proper releases yet. | |
1060 | (define-public kaldi | |
0877b74f RW |
1061 | (let ((commit "d4791c0f3fc1a09c042dac365e120899ee2ad21e") |
1062 | (revision "2")) | |
b9445d0b RW |
1063 | (package |
1064 | (name "kaldi") | |
1065 | (version (git-version "0" revision commit)) | |
1066 | (source (origin | |
1067 | (method git-fetch) | |
1068 | (uri (git-reference | |
1069 | (url "https://github.com/kaldi-asr/kaldi.git") | |
1070 | (commit commit))) | |
1071 | (file-name (git-file-name name version)) | |
1072 | (sha256 | |
1073 | (base32 | |
0877b74f | 1074 | "07k80my6f19mhrkwbzhjsnpf9871wmrwkl0ym468i830w67qyjrz")))) |
b9445d0b RW |
1075 | (build-system gnu-build-system) |
1076 | (arguments | |
1077 | `(#:test-target "test" | |
1078 | #:phases | |
1079 | (modify-phases %standard-phases | |
1080 | (add-after 'unpack 'chdir | |
1081 | (lambda _ (chdir "src") #t)) | |
1082 | (replace 'configure | |
1083 | (lambda* (#:key build system inputs outputs #:allow-other-keys) | |
1084 | (when (not (or (string-prefix? "x86_64" system) | |
1085 | (string-prefix? "i686" system))) | |
1086 | (substitute* "makefiles/linux_openblas.mk" | |
1087 | (("-msse -msse2") ""))) | |
1088 | (substitute* "makefiles/default_rules.mk" | |
1089 | (("/bin/bash") (which "bash"))) | |
1090 | (substitute* "Makefile" | |
1091 | (("ext_depend: check_portaudio") | |
1092 | "ext_depend:")) | |
1093 | (substitute* '("online/Makefile" | |
1094 | "onlinebin/Makefile" | |
1095 | "gst-plugin/Makefile") | |
1096 | (("../../tools/portaudio/install") | |
1097 | (assoc-ref inputs "portaudio"))) | |
1098 | ||
1099 | ;; This `configure' script doesn't support variables passed as | |
1100 | ;; arguments, nor does it support "prefix". | |
1101 | (let ((out (assoc-ref outputs "out")) | |
1102 | (openblas (assoc-ref inputs "openblas")) | |
1103 | (openfst (assoc-ref inputs "openfst"))) | |
1104 | (substitute* "configure" | |
1105 | (("check_for_slow_expf;") "") | |
1106 | ;; This affects the RPATH and also serves as the installation | |
1107 | ;; directory. | |
1108 | (("KALDILIBDIR=`pwd`/lib") | |
1109 | (string-append "KALDILIBDIR=" out "/lib"))) | |
1110 | (mkdir-p out) ; must exist | |
1111 | (setenv "CONFIG_SHELL" (which "bash")) | |
1112 | (setenv "OPENFST_VER" ,(package-version openfst)) | |
1113 | (invoke "./configure" | |
1114 | "--use-cuda=no" | |
1115 | "--shared" | |
1116 | (string-append "--openblas-root=" openblas) | |
1117 | (string-append "--fst-root=" openfst))))) | |
1118 | (add-after 'build 'build-ext-and-gstreamer-plugin | |
1119 | (lambda _ | |
1120 | (invoke "make" "-C" "online" "depend") | |
1121 | (invoke "make" "-C" "online") | |
1122 | (invoke "make" "-C" "onlinebin" "depend") | |
1123 | (invoke "make" "-C" "onlinebin") | |
1124 | (invoke "make" "-C" "gst-plugin" "depend") | |
1125 | (invoke "make" "-C" "gst-plugin") | |
1126 | #t)) | |
1127 | ;; TODO: also install the executables. | |
1128 | (replace 'install | |
1129 | (lambda* (#:key outputs #:allow-other-keys) | |
1130 | (let* ((out (assoc-ref outputs "out")) | |
1fdd20c7 | 1131 | (inc (string-append out "/include")) |
b9445d0b RW |
1132 | (lib (string-append out "/lib"))) |
1133 | (mkdir-p lib) | |
1fdd20c7 RW |
1134 | ;; The build phase installed symlinks to the actual |
1135 | ;; libraries. Install the actual targets. | |
1136 | (for-each (lambda (file) | |
1137 | (let ((target (readlink file))) | |
1138 | (delete-file file) | |
1139 | (install-file target lib))) | |
1140 | (find-files lib "\\.so")) | |
1141 | ;; Install headers | |
1142 | (for-each (lambda (file) | |
1143 | (let ((target-dir (string-append inc "/" (dirname file)))) | |
1144 | (install-file file target-dir))) | |
1145 | (find-files "." "\\.h")) | |
1146 | (install-file "gst-plugin/libgstonlinegmmdecodefaster.so" | |
1147 | (string-append lib "/gstreamer-1.0")) | |
b9445d0b RW |
1148 | #t)))))) |
1149 | (inputs | |
1150 | `(("alsa-lib" ,alsa-lib) | |
1151 | ("gfortran" ,gfortran "lib") | |
1152 | ("glib" ,glib) | |
1153 | ("gstreamer" ,gstreamer) | |
1154 | ("jack" ,jack-1) | |
1155 | ("openblas" ,openblas) | |
1156 | ("openfst" ,openfst) | |
1157 | ("portaudio" ,portaudio) | |
1158 | ("python" ,python))) | |
1159 | (native-inputs | |
1160 | `(("glib" ,glib "bin") ; glib-genmarshal | |
1161 | ("grep" ,grep) | |
1162 | ("sed" ,sed) | |
1163 | ("pkg-config" ,pkg-config) | |
1164 | ("which" ,which))) | |
1165 | (home-page "https://kaldi-asr.org/") | |
1166 | (synopsis "Speech recognition toolkit") | |
1167 | (description "Kaldi is an extensible toolkit for speech recognition | |
1168 | written in C++.") | |
1169 | (license license:asl2.0)))) | |
99260014 RW |
1170 | |
1171 | (define-public gst-kaldi-nnet2-online | |
b3cf5f86 RW |
1172 | (let ((commit "cb227ef43b66a9835c14eb0ad39e08ee03c210ad") |
1173 | (revision "2")) | |
99260014 RW |
1174 | (package |
1175 | (name "gst-kaldi-nnet2-online") | |
1176 | (version (git-version "0" revision commit)) | |
1177 | (source (origin | |
1178 | (method git-fetch) | |
1179 | (uri (git-reference | |
1180 | (url "https://github.com/alumae/gst-kaldi-nnet2-online.git") | |
1181 | (commit commit))) | |
1182 | (file-name (git-file-name name version)) | |
1183 | (sha256 | |
1184 | (base32 | |
b3cf5f86 | 1185 | "1i6ffwiavxx07ri0lxix6s8q0r31x7i4xxvhys5jxkixf5q34w8g")))) |
99260014 RW |
1186 | (build-system gnu-build-system) |
1187 | (arguments | |
1188 | `(#:tests? #f ; there are none | |
1189 | #:make-flags | |
1190 | (list (string-append "SHELL=" | |
1191 | (assoc-ref %build-inputs "bash") "/bin/bash") | |
1192 | (string-append "KALDI_ROOT=" | |
1193 | (assoc-ref %build-inputs "kaldi-src")) | |
1194 | (string-append "KALDILIBDIR=" | |
1195 | (assoc-ref %build-inputs "kaldi") "/lib") | |
1196 | "KALDI_FLAVOR=dynamic") | |
1197 | #:phases | |
1198 | (modify-phases %standard-phases | |
1199 | (add-after 'unpack 'chdir | |
1200 | (lambda _ (chdir "src") #t)) | |
1201 | (replace 'configure | |
1202 | (lambda* (#:key inputs #:allow-other-keys) | |
1203 | (let ((glib (assoc-ref inputs "glib"))) | |
ad60a348 | 1204 | (setenv "CXXFLAGS" "-fPIC") |
99260014 RW |
1205 | (setenv "CPLUS_INCLUDE_PATH" |
1206 | (string-append glib "/include/glib-2.0:" | |
1207 | glib "/lib/glib-2.0/include:" | |
1208 | (assoc-ref inputs "gstreamer") | |
ad60a348 | 1209 | "/include/gstreamer-1.0"))) |
99260014 RW |
1210 | (substitute* "Makefile" |
1211 | (("include \\$\\(KALDI_ROOT\\)/src/kaldi.mk") "") | |
ad60a348 MB |
1212 | (("\\$\\(error Cannot find") "#")) |
1213 | #t)) | |
99260014 RW |
1214 | (add-before 'build 'build-depend |
1215 | (lambda* (#:key make-flags #:allow-other-keys) | |
1216 | (apply invoke "make" "depend" make-flags))) | |
1217 | (replace 'install | |
1218 | (lambda* (#:key outputs #:allow-other-keys) | |
1219 | (let* ((out (assoc-ref outputs "out")) | |
1220 | (lib (string-append out "/lib/gstreamer-1.0"))) | |
1221 | (install-file "libgstkaldinnet2onlinedecoder.so" lib) | |
1222 | #t)))))) | |
1223 | (inputs | |
1224 | `(("glib" ,glib) | |
1225 | ("gstreamer" ,gstreamer) | |
1226 | ("jansson" ,jansson) | |
1227 | ("openfst" ,openfst) | |
1228 | ("kaldi" ,kaldi))) | |
1229 | (native-inputs | |
1230 | `(("bash" ,bash) | |
1231 | ("glib:bin" ,glib "bin") ; glib-genmarshal | |
1232 | ("kaldi-src" ,(package-source kaldi)) | |
1233 | ("pkg-config" ,pkg-config))) | |
1234 | (home-page "https://kaldi-asr.org/") | |
1235 | (synopsis "Gstreamer plugin for decoding speech") | |
1236 | (description "This package provides a GStreamer plugin that wraps | |
1237 | Kaldi's @code{SingleUtteranceNnet2Decoder}. It requires iVector-adapted DNN | |
1238 | acoustic models. The iVectors are adapted to the current audio stream | |
1239 | automatically.") | |
1240 | (license license:asl2.0)))) | |
10451f6b RW |
1241 | |
1242 | (define-public kaldi-gstreamer-server | |
1228c2ab RW |
1243 | ;; This is the tip of the py3 branch |
1244 | (let ((commit "f68cab490be7eb0da2af1475fbc16655f50a60cb") | |
1245 | (revision "2")) | |
10451f6b RW |
1246 | (package |
1247 | (name "kaldi-gstreamer-server") | |
1248 | (version (git-version "0" revision commit)) | |
1249 | (source (origin | |
1250 | (method git-fetch) | |
1251 | (uri (git-reference | |
1252 | (url "https://github.com/alumae/kaldi-gstreamer-server.git") | |
1253 | (commit commit))) | |
1254 | (file-name (git-file-name name version)) | |
1255 | (sha256 | |
1256 | (base32 | |
1228c2ab | 1257 | "17lh1368vkg8ngrcbn2phvigzlmalrqg6djx2gg61qq1a0nj87dm")))) |
10451f6b RW |
1258 | (build-system gnu-build-system) |
1259 | (arguments | |
1260 | `(#:tests? #f ; there are no tests that can be run automatically | |
1261 | #:modules ((guix build utils) | |
1262 | (guix build gnu-build-system) | |
1263 | (srfi srfi-26)) | |
1264 | #:phases | |
1265 | (modify-phases %standard-phases | |
1266 | (delete 'configure) | |
1267 | (replace 'build | |
1268 | (lambda* (#:key outputs #:allow-other-keys) | |
1269 | ;; Disable hash randomization to ensure the generated .pycs | |
1270 | ;; are reproducible. | |
1271 | (setenv "PYTHONHASHSEED" "0") | |
1272 | (with-directory-excursion "kaldigstserver" | |
46d07f84 RW |
1273 | ;; See https://github.com/alumae/kaldi-gstreamer-server/issues/232 |
1274 | (substitute* "master_server.py" | |
1275 | (("\\.replace\\('\\\\.*") ")")) | |
1276 | ||
1228c2ab RW |
1277 | ;; This is a Python 2 file |
1278 | (delete-file "decoder_test.py") | |
1279 | (delete-file "test-buffer.py") | |
1280 | ||
10451f6b RW |
1281 | (for-each (lambda (file) |
1282 | (apply invoke | |
1283 | `("python" | |
1284 | "-m" "compileall" | |
1285 | "-f" ; force rebuild | |
1286 | ,file))) | |
1287 | (find-files "." "\\.py$"))) | |
1288 | #t)) | |
1289 | (replace 'install | |
1290 | (lambda* (#:key inputs outputs #:allow-other-keys) | |
1291 | (let* ((out (assoc-ref outputs "out")) | |
1292 | (bin (string-append out "/bin")) | |
1293 | (share (string-append out "/share/kaldi-gstreamer-server/"))) | |
1294 | ;; Install Python files | |
1295 | (with-directory-excursion "kaldigstserver" | |
1296 | (for-each (cut install-file <> share) | |
1297 | (find-files "." ".*"))) | |
1298 | ||
1299 | ;; Install sample configuration files | |
1300 | (for-each (cut install-file <> share) | |
1301 | (find-files "." "\\.yaml")) | |
1302 | ||
1303 | ;; Install executables | |
1304 | (mkdir-p bin) | |
1305 | (let* ((server (string-append bin "/kaldi-gst-server")) | |
1306 | (client (string-append bin "/kaldi-gst-client")) | |
1307 | (worker (string-append bin "/kaldi-gst-worker")) | |
1308 | (PYTHONPATH (getenv "PYTHONPATH")) | |
1309 | (GST_PLUGIN_PATH (string-append | |
1310 | (assoc-ref inputs "gst-kaldi-nnet2-online") | |
1311 | "/lib/gstreamer-1.0:${GST_PLUGIN_PATH}")) | |
1312 | (wrap (lambda (wrapper what) | |
1313 | (with-output-to-file wrapper | |
1314 | (lambda _ | |
1315 | (format #t | |
1316 | "#!~a | |
1317 | export PYTHONPATH=~a | |
1318 | export GST_PLUGIN_PATH=~a | |
1319 | exec ~a ~a/~a \"$@\"~%" | |
1320 | (which "bash") PYTHONPATH GST_PLUGIN_PATH | |
1321 | (which "python") share what))) | |
1322 | (chmod wrapper #o555)))) | |
1323 | (for-each wrap | |
1324 | (list server client worker) | |
1325 | (list "master_server.py" | |
1326 | "client.py" | |
1327 | "worker.py"))) | |
1328 | #t)))))) | |
1329 | (inputs | |
1330 | `(("gst-kaldi-nnet2-online" ,gst-kaldi-nnet2-online) | |
1228c2ab RW |
1331 | ("python" ,python-wrapper) |
1332 | ("python-pygobject" ,python-pygobject) | |
1333 | ("python-pyyaml" ,python-pyyaml) | |
cb44af24 | 1334 | ("python-tornado" ,python-tornado-6))) |
10451f6b RW |
1335 | (home-page "https://github.com/alumae/kaldi-gstreamer-server") |
1336 | (synopsis "Real-time full-duplex speech recognition server") | |
1337 | (description "This is a real-time full-duplex speech recognition server, | |
1338 | based on the Kaldi toolkit and the GStreamer framework and implemented in | |
1339 | Python.") | |
1340 | (license license:bsd-2)))) | |
0dfeb285 | 1341 | |
4fa16c9a RW |
1342 | ;; Note that Tensorflow includes a "third_party" directory, which seems to not |
1343 | ;; only contain modified subsets of upstream library source code, but also | |
1344 | ;; adapter headers provided by Google (such as the fft.h header, which is not | |
1345 | ;; part of the upstream project code). The Tensorflow code includes headers | |
1346 | ;; from the "third_party" directory. It does not look like we can replace | |
1347 | ;; these headers with unmodified upstream files, so we keep them. | |
1348 | (define-public tensorflow | |
1349 | (package | |
1350 | (name "tensorflow") | |
1351 | (version "1.9.0") | |
1352 | (source | |
1353 | (origin | |
1354 | (method git-fetch) | |
1355 | (uri (git-reference | |
1356 | (url "https://github.com/tensorflow/tensorflow.git") | |
1357 | (commit (string-append "v" version)))) | |
1358 | (file-name (string-append "tensorflow-" version "-checkout")) | |
1359 | (sha256 | |
1360 | (base32 | |
1361 | "0a9kwha395g3wgxfwln5j8vn9nkspmd75xldrlqdq540w996g8xa")))) | |
1362 | (build-system cmake-build-system) | |
1363 | (arguments | |
1364 | `(#:tests? #f ; no "check" target | |
1365 | #:build-type "Release" | |
1366 | #:configure-flags | |
1367 | (let ((protobuf (assoc-ref %build-inputs "protobuf")) | |
1368 | (protobuf:native (assoc-ref %build-inputs "protobuf:native")) | |
1369 | (jsoncpp (assoc-ref %build-inputs "jsoncpp")) | |
1370 | (snappy (assoc-ref %build-inputs "snappy")) | |
1371 | (sqlite (assoc-ref %build-inputs "sqlite"))) | |
1372 | (list | |
1373 | ;; Use protobuf from Guix | |
1374 | (string-append "-Dprotobuf_STATIC_LIBRARIES=" | |
1375 | protobuf "/lib/libprotobuf.so") | |
1376 | (string-append "-DPROTOBUF_PROTOC_EXECUTABLE=" | |
1377 | protobuf:native "/bin/protoc") | |
1378 | ||
1379 | ;; Use snappy from Guix | |
1380 | (string-append "-Dsnappy_STATIC_LIBRARIES=" | |
1381 | snappy "/lib/libsnappy.so") | |
1382 | ;; Yes, this is not actually the include directory but a prefix... | |
1383 | (string-append "-Dsnappy_INCLUDE_DIR=" snappy) | |
1384 | ||
1385 | ;; Use jsoncpp from Guix | |
1386 | (string-append "-Djsoncpp_STATIC_LIBRARIES=" | |
1387 | jsoncpp "/lib/libjsoncpp.so") | |
1388 | ;; Yes, this is not actually the include directory but a prefix... | |
1389 | (string-append "-Djsoncpp_INCLUDE_DIR=" jsoncpp) | |
1390 | ||
1391 | ;; Use sqlite from Guix | |
1392 | (string-append "-Dsqlite_STATIC_LIBRARIES=" | |
1393 | sqlite "/lib/libsqlite.a") | |
1394 | ||
1395 | ;; Use system libraries wherever possible. Currently, this | |
1396 | ;; only affects zlib. | |
1397 | "-Dsystemlib_ALL=ON" | |
1398 | "-Dtensorflow_ENABLE_POSITION_INDEPENDENT_CODE=ON" | |
1399 | "-Dtensorflow_BUILD_SHARED_LIB=ON" | |
1400 | "-Dtensorflow_OPTIMIZE_FOR_NATIVE_ARCH=OFF" | |
1401 | "-Dtensorflow_ENABLE_SSL_SUPPORT=OFF" | |
1402 | "-Dtensorflow_BUILD_CONTRIB_KERNELS=OFF")) | |
1403 | #:make-flags | |
1404 | (list "CC=gcc") | |
1405 | #:modules ((ice-9 ftw) | |
1406 | (guix build utils) | |
0b967058 EF |
1407 | (guix build cmake-build-system) |
1408 | ((guix build python-build-system) | |
1409 | #:select (python-version))) | |
1410 | #:imported-modules (,@%cmake-build-system-modules | |
1411 | (guix build python-build-system)) | |
4fa16c9a RW |
1412 | #:phases |
1413 | (modify-phases %standard-phases | |
1414 | (add-after 'unpack 'set-source-file-times-to-1980 | |
1415 | ;; At the end of the tf_python_build_pip_package target, a ZIP | |
1416 | ;; archive should be generated via bdist_wheel, but it fails with | |
1417 | ;; "ZIP does not support timestamps before 1980". Luckily, | |
1418 | ;; SOURCE_DATE_EPOCH is respected, which we set to some time in | |
1419 | ;; 1980. | |
1420 | (lambda _ (setenv "SOURCE_DATE_EPOCH" "315532800") #t)) | |
1421 | ;; See https://github.com/tensorflow/tensorflow/issues/20517#issuecomment-406373913 | |
1422 | (add-after 'unpack 'python3.7-compatibility | |
1423 | (lambda _ | |
1424 | (substitute* '("tensorflow/python/eager/pywrap_tfe_src.cc" | |
1425 | "tensorflow/python/lib/core/ndarray_tensor.cc" | |
1426 | "tensorflow/python/lib/core/py_func.cc") | |
1427 | (("PyUnicode_AsUTF8") "(char *)PyUnicode_AsUTF8")) | |
1428 | (substitute* "tensorflow/c/eager/c_api.h" | |
1429 | (("unsigned char async") | |
1430 | "unsigned char is_async")) | |
1431 | ||
1432 | ;; Remove dependency on tensorboard, a complicated but probably | |
1433 | ;; optional package. | |
1434 | (substitute* "tensorflow/tools/pip_package/setup.py" | |
1435 | ((".*'tensorboard >.*") "")) | |
0b967058 EF |
1436 | |
1437 | ;; Fix the build with python-3.8, taken from rejected upstream patch: | |
1438 | ;; https://github.com/tensorflow/tensorflow/issues/34197 | |
1439 | (substitute* (find-files "tensorflow/python" ".*\\.cc$") | |
1440 | (("(nullptr,)(\\ +/. tp_print)" _ _ tp_print) | |
1441 | (string-append "NULL, " tp_print))) | |
4fa16c9a RW |
1442 | #t)) |
1443 | (add-after 'python3.7-compatibility 'chdir | |
1444 | (lambda _ (chdir "tensorflow/contrib/cmake") #t)) | |
1445 | (add-after 'chdir 'disable-downloads | |
1446 | (lambda* (#:key inputs #:allow-other-keys) | |
1447 | (substitute* (find-files "external" "\\.cmake$") | |
1448 | (("GIT_REPOSITORY.*") "") | |
1449 | (("GIT_TAG.*") "") | |
1450 | (("PREFIX ") | |
1451 | "DOWNLOAD_COMMAND \"\"\nPREFIX ")) | |
1452 | ||
1453 | ;; Use packages from Guix | |
1454 | (let ((grpc (assoc-ref inputs "grpc"))) | |
1455 | (substitute* "CMakeLists.txt" | |
1456 | ;; Sqlite | |
1457 | (("include\\(sqlite\\)") "") | |
1458 | (("\\$\\{sqlite_STATIC_LIBRARIES\\}") | |
1459 | (string-append (assoc-ref inputs "sqlite") | |
1460 | "/lib/libsqlite3.so")) | |
1461 | (("sqlite_copy_headers_to_destination") "") | |
1462 | ||
1463 | ;; PNG | |
1464 | (("include\\(png\\)") "") | |
1465 | (("\\$\\{png_STATIC_LIBRARIES\\}") | |
1466 | (string-append (assoc-ref inputs "libpng") | |
1467 | "/lib/libpng16.so")) | |
1468 | (("png_copy_headers_to_destination") "") | |
1469 | ||
1470 | ;; JPEG | |
1471 | (("include\\(jpeg\\)") "") | |
1472 | (("\\$\\{jpeg_STATIC_LIBRARIES\\}") | |
1473 | (string-append (assoc-ref inputs "libjpeg") | |
1474 | "/lib/libjpeg.so")) | |
1475 | (("jpeg_copy_headers_to_destination") "") | |
1476 | ||
1477 | ;; GIF | |
1478 | (("include\\(gif\\)") "") | |
1479 | (("\\$\\{gif_STATIC_LIBRARIES\\}") | |
1480 | (string-append (assoc-ref inputs "giflib") | |
1481 | "/lib/libgif.so")) | |
1482 | (("gif_copy_headers_to_destination") "") | |
1483 | ||
1484 | ;; lmdb | |
1485 | (("include\\(lmdb\\)") "") | |
1486 | (("\\$\\{lmdb_STATIC_LIBRARIES\\}") | |
1487 | (string-append (assoc-ref inputs "lmdb") | |
1488 | "/lib/liblmdb.so")) | |
1489 | (("lmdb_copy_headers_to_destination") "") | |
1490 | ||
1491 | ;; Protobuf | |
1492 | (("include\\(protobuf\\)") "") | |
1493 | (("protobuf_copy_headers_to_destination") "") | |
1494 | (("^ +protobuf") "") | |
1495 | ||
1496 | ;; gRPC | |
1497 | (("include\\(grpc\\)") | |
1498 | "find_package(grpc REQUIRED NAMES gRPC)") | |
1499 | (("list\\(APPEND tensorflow_EXTERNAL_DEPENDENCIES grpc\\)") "") | |
1500 | ||
1501 | ;; Eigen | |
1502 | (("include\\(eigen\\)") | |
1503 | (string-append "find_package(eigen REQUIRED NAMES Eigen3) | |
1504 | set(eigen_INCLUDE_DIRS ${CMAKE_CURRENT_BINARY_DIR}/external/eigen_archive " | |
1505 | (assoc-ref inputs "eigen") "/include/eigen3)")) | |
1506 | (("^ +eigen") "") | |
1507 | ||
1508 | ;; snappy | |
1509 | (("include\\(snappy\\)") | |
1510 | "add_definitions(-DTF_USE_SNAPPY)") | |
1511 | (("list\\(APPEND tensorflow_EXTERNAL_DEPENDENCIES snappy\\)") "") | |
1512 | ||
1513 | ;; jsoncpp | |
1514 | (("include\\(jsoncpp\\)") "") | |
1515 | (("^ +jsoncpp") "")) | |
1516 | ||
1517 | (substitute* "tf_core_framework.cmake" | |
1518 | ((" grpc") "") | |
1519 | (("\\$\\{GRPC_BUILD\\}/grpc_cpp_plugin") | |
1520 | (which "grpc_cpp_plugin")) | |
1521 | ;; Link with gRPC libraries | |
1522 | (("add_library\\(tf_protos_cc.*" m) | |
1523 | (string-append m | |
1524 | (format #f "\ntarget_link_libraries(tf_protos_cc PRIVATE \ | |
1525 | ~a/lib/libgrpc++_unsecure.a \ | |
1526 | ~a/lib/libgrpc_unsecure.a \ | |
1527 | ~a/lib/libaddress_sorting.a \ | |
1528 | ~a/lib/libgpr.a \ | |
1529 | ~a//lib/libcares.so | |
1530 | )\n" | |
1531 | grpc grpc grpc grpc | |
1532 | (assoc-ref inputs "c-ares")))))) | |
1533 | (substitute* "tf_tools.cmake" | |
1534 | (("add_dependencies\\(\\$\\{proto_text.*") "")) | |
1535 | ;; Remove dependency on bundled grpc | |
1536 | (substitute* "tf_core_distributed_runtime.cmake" | |
1537 | (("tf_core_cpu grpc") "tf_core_cpu")) | |
1538 | ||
1539 | ;; This directory is a dependency of many targets. | |
1540 | (mkdir-p "protobuf") | |
1541 | #t)) | |
1542 | (add-after 'configure 'unpack-third-party-sources | |
1543 | (lambda* (#:key inputs #:allow-other-keys) | |
1544 | ;; This is needed to configure bundled packages properly. | |
1545 | (setenv "CONFIG_SHELL" (which "bash")) | |
1546 | (for-each | |
1547 | (lambda (name) | |
1548 | (let* ((what (assoc-ref inputs (string-append name "-src"))) | |
1549 | (name* (string-map (lambda (c) | |
1550 | (if (char=? c #\-) | |
1551 | #\_ c)) name)) | |
1552 | (where (string-append "../build/" name* "/src/" name*))) | |
1553 | (cond | |
1554 | ((string-suffix? ".zip" what) | |
1555 | (mkdir-p where) | |
1556 | (with-directory-excursion where | |
1557 | (invoke "unzip" what))) | |
1558 | ((string-suffix? ".tar.gz" what) | |
1559 | (mkdir-p where) | |
1560 | (invoke "tar" "xf" what | |
1561 | "-C" where "--strip-components=1")) | |
1562 | (else | |
1563 | (let ((parent (dirname where))) | |
1564 | (mkdir-p parent) | |
1565 | (with-directory-excursion parent | |
1566 | (when (file-exists? name*) | |
1567 | (delete-file-recursively name*)) | |
1568 | (copy-recursively what name*) | |
1569 | (map make-file-writable | |
1570 | (find-files name* ".*")))))))) | |
1571 | (list "boringssl" | |
1572 | "cub" | |
1573 | "double-conversion" | |
1574 | "farmhash" | |
1575 | "fft2d" | |
1576 | "highwayhash" | |
1577 | "nsync" | |
1578 | "re2")) | |
1579 | ||
1580 | (rename-file "../build/cub/src/cub/cub-1.8.0/" | |
1581 | "../build/cub/src/cub/cub/") | |
1582 | #t)) | |
1583 | (add-after 'unpack 'fix-python-build | |
1584 | (lambda* (#:key inputs outputs #:allow-other-keys) | |
1585 | (mkdir-p "protobuf-src") | |
1586 | (invoke "tar" "xf" (assoc-ref inputs "protobuf:src") | |
1587 | "-C" "protobuf-src" "--strip-components=1") | |
1588 | (mkdir-p "eigen-src") | |
1589 | (invoke "tar" "xf" (assoc-ref inputs "eigen:src") | |
1590 | "-C" "eigen-src" "--strip-components=1") | |
1591 | ||
1592 | (substitute* "tensorflow/contrib/cmake/tf_python.cmake" | |
1593 | ;; Ensure that all Python dependencies can be found at build time. | |
1594 | (("PYTHONPATH=\\$\\{CMAKE_CURRENT_BINARY_DIR\\}/tf_python" m) | |
1595 | (string-append m ":" (getenv "PYTHONPATH"))) | |
1596 | ;; Take protobuf source files from our source package. | |
1597 | (("\\$\\{CMAKE_CURRENT_BINARY_DIR\\}/protobuf/src/protobuf/src/google") | |
1598 | (string-append (getcwd) "/protobuf-src/src/google"))) | |
1599 | ||
1600 | (substitute* '("tensorflow/contrib/cmake/tf_shared_lib.cmake" | |
1601 | "tensorflow/contrib/cmake/tf_python.cmake") | |
1602 | ;; Take Eigen source files from our source package. | |
1603 | (("\\$\\{CMAKE_CURRENT_BINARY_DIR\\}/eigen/src/eigen/") | |
1604 | (string-append (getcwd) "/eigen-src/")) | |
1605 | ;; Take Eigen headers from our own package. | |
1606 | (("\\$\\{CMAKE_CURRENT_BINARY_DIR\\}/external/eigen_archive") | |
1607 | (string-append (assoc-ref inputs "eigen") "/include/eigen3"))) | |
1608 | ||
1609 | ;; Correct the RUNPATH of ops libraries generated for Python. | |
1610 | ;; TODO: this doesn't work :( | |
1611 | ;; /gnu/store/...-tensorflow-1.9.0/lib/python3.7/site-packages/tensorflow/contrib/seq2seq/python/ops/lib_beam_search_ops.so: | |
1612 | ;; warning: RUNPATH contains bogus entries: ("/tmp/guix-build-tensorflow-1.9.0.drv-0/source/tensorflow/contrib/build") | |
1613 | ;; /gnu/store/...-tensorflow-1.9.0/lib/python3.7/site-packages/tensorflow/contrib/seq2seq/python/ops/lib_beam_search_ops.so: | |
1614 | ;; error: depends on 'libpywrap_tensorflow_internal.so', which | |
1615 | ;; cannot be found in RUNPATH ... | |
1616 | (substitute* "tensorflow/contrib/cmake/tf_cc_ops.cmake" | |
1617 | (("set_target_properties.*") | |
1618 | (string-append "set_target_properties(${_AT_TARGET} PROPERTIES \ | |
1619 | COMPILE_FLAGS ${target_compile_flags} \ | |
1620 | INSTALL_RPATH_USE_LINK_PATH TRUE \ | |
1621 | INSTALL_RPATH " (assoc-ref outputs "out") "/lib)\n"))) | |
1622 | #t)) | |
1623 | (add-after 'build 'build-pip-package | |
1624 | (lambda* (#:key outputs #:allow-other-keys) | |
1625 | (setenv "LDFLAGS" | |
1626 | (string-append "-Wl,-rpath=" | |
1627 | (assoc-ref outputs "out") "/lib")) | |
1628 | (invoke "make" "tf_python_build_pip_package") | |
1629 | #t)) | |
1630 | (add-after 'build-pip-package 'install-python | |
0b967058 | 1631 | (lambda* (#:key inputs outputs #:allow-other-keys) |
4fa16c9a | 1632 | (let ((out (assoc-ref outputs "out")) |
0b967058 EF |
1633 | (wheel (car (find-files "../build/tf_python/dist/" "\\.whl$"))) |
1634 | (python-version (python-version | |
1635 | (assoc-ref inputs "python")))) | |
4fa16c9a RW |
1636 | (invoke "python" "-m" "pip" "install" wheel |
1637 | (string-append "--prefix=" out)) | |
1638 | ||
1639 | ;; XXX: broken RUNPATH, see fix-python-build phase. | |
1640 | (delete-file | |
1641 | (string-append | |
0b967058 EF |
1642 | out "/lib/python" python-version |
1643 | "/site-packages/tensorflow/contrib/" | |
4fa16c9a RW |
1644 | "seq2seq/python/ops/lib_beam_search_ops.so")) |
1645 | #t)))))) | |
1646 | (native-inputs | |
1647 | `(("pkg-config" ,pkg-config) | |
7373eb83 MB |
1648 | ("protobuf:native" ,protobuf-3.6) ; protoc |
1649 | ("protobuf:src" ,(package-source protobuf-3.6)) | |
4fa16c9a | 1650 | ("eigen:src" ,(package-source eigen-for-tensorflow)) |
0fdec2a3 MB |
1651 | ;; install_pip_packages.sh wants setuptools 39.1.0 specifically. |
1652 | ("python-setuptools" ,python-setuptools-for-tensorflow) | |
1653 | ||
4fa16c9a RW |
1654 | ;; The commit hashes and URLs for third-party source code are taken |
1655 | ;; from "tensorflow/workspace.bzl". | |
1656 | ("boringssl-src" | |
1657 | ,(let ((commit "ee7aa02") | |
1658 | (revision "1")) | |
1659 | (origin | |
1660 | (method git-fetch) | |
1661 | (uri (git-reference | |
1662 | (url "https://boringssl.googlesource.com/boringssl") | |
1663 | (commit commit))) | |
1664 | (file-name (string-append "boringssl-0-" revision | |
1665 | (string-take commit 7) | |
1666 | "-checkout")) | |
1667 | (sha256 | |
1668 | (base32 | |
1669 | "1jf693q0nw0adsic6cgmbdx6g7wr4rj4vxa8j1hpn792fqhd8wgw"))))) | |
1670 | ("cub-src" | |
1671 | ,(let ((version "1.8.0")) | |
1672 | (origin | |
1673 | (method url-fetch) | |
1674 | (uri (string-append "https://mirror.bazel.build/github.com/NVlabs/" | |
1675 | "cub/archive/" version ".zip")) | |
1676 | (file-name (string-append "cub-" version ".zip")) | |
1677 | (sha256 | |
1678 | (base32 | |
1679 | "1hsqikqridb90dkxkjr2918dcry6pfh46ccnwrzawl56aamhdykb"))))) | |
1680 | ("double-conversion-src" | |
1681 | ,(let ((commit "5664746") | |
1682 | (revision "1")) | |
1683 | (origin | |
1684 | (method git-fetch) | |
1685 | (uri (git-reference | |
1686 | (url "https://github.com/google/double-conversion.git") | |
1687 | (commit commit))) | |
1688 | (file-name | |
1689 | (git-file-name "double-conversion" | |
1690 | (string-append "0-" revision "." | |
1691 | (string-take commit 7)))) | |
1692 | (sha256 | |
1693 | (base32 | |
1694 | "1h5lppqqxcvdg5jq42i5msgwx20ryij3apvmndflngrgdpc04gn1"))))) | |
1695 | ("farmhash-src" | |
1696 | ,(let ((commit "816a4ae622e964763ca0862d9dbd19324a1eaf45")) | |
1697 | (origin | |
1698 | (method url-fetch) | |
1699 | (uri (string-append | |
1700 | "https://mirror.bazel.build/github.com/google/farmhash/archive/" | |
1701 | commit ".tar.gz")) | |
1702 | (file-name (string-append "farmhash-0-" (string-take commit 7) | |
1703 | ".tar.gz")) | |
1704 | (sha256 | |
1705 | (base32 | |
1706 | "185b2xdxl4d4cnsnv6abg8s22gxvx8673jq2yaq85bz4cdy58q35"))))) | |
1707 | ;; The license notice on the home page at | |
1708 | ;; http://www.kurims.kyoto-u.ac.jp/~ooura/fft.html says: | |
1709 | ;; Copyright Takuya OOURA, 1996-2001 | |
1710 | ;; | |
1711 | ;; You may use, copy, modify and distribute this code for any purpose | |
1712 | ;; (include commercial use) and without fee. Please refer to this | |
1713 | ;; package when you modify this code. | |
1714 | ;; | |
1715 | ;; We take the identical tarball from the Bazel mirror, because the URL | |
1716 | ;; at the home page is not versioned and might change. | |
1717 | ("fft2d-src" | |
1718 | ,(origin | |
1719 | (method url-fetch) | |
1720 | (uri "https://mirror.bazel.build/www.kurims.kyoto-u.ac.jp/~ooura/fft.tgz") | |
1721 | (file-name "fft2d.tar.gz") | |
1722 | (sha256 | |
1723 | (base32 | |
1724 | "15jjkfvhqvl2c0753d2di8hz0pyzn598g74wqy79awdrf1y67fsj")))) | |
1725 | ("highwayhash-src" | |
1726 | ,(let ((commit "be5edafc2e1a455768e260ccd68ae7317b6690ee") | |
1727 | (revision "1")) | |
1728 | (origin | |
1729 | (method git-fetch) | |
1730 | (uri (git-reference | |
1731 | (url "https://github.com/google/highwayhash.git") | |
1732 | (commit commit))) | |
1733 | (file-name (string-append "highwayhash-0-" revision | |
1734 | (string-take commit 7) | |
1735 | "-checkout")) | |
1736 | (sha256 | |
1737 | (base32 | |
1738 | "154jwf98cyy54hldr94pgjn85zynly3abpnc1avmb8a18lzwjyb6"))))) | |
1739 | ("nsync-src" | |
1740 | ,(let ((version "0559ce013feac8db639ee1bf776aca0325d28777") | |
1741 | (revision "1")) | |
1742 | (origin | |
1743 | (method url-fetch) | |
1744 | (uri (string-append "https://mirror.bazel.build/" | |
1745 | "github.com/google/nsync/archive/" | |
1746 | version ".tar.gz")) | |
1747 | (file-name (string-append "nsync-0." revision | |
1748 | "-" (string-take version 7) | |
1749 | ".tar.gz")) | |
1750 | (sha256 | |
1751 | (base32 | |
1752 | "0qdkyqym34x739mmzv97ah5r7ph462v5xkxqxvidmcfqbi64b132"))))) | |
1753 | ("re2-src" | |
1754 | ,(let ((commit "e7efc48") | |
1755 | (revision "1")) | |
1756 | (origin | |
1757 | (method git-fetch) | |
1758 | (uri (git-reference | |
1759 | (url "https://github.com/google/re2") | |
1760 | (commit commit))) | |
1761 | (file-name (string-append "re2-0-" revision | |
1762 | (string-take commit 7) | |
1763 | "-checkout")) | |
1764 | (sha256 | |
1765 | (base32 | |
1766 | "161g9841rjfsy5pn52fcis0s9hdr7rxvb06pad38j5rppfihvign"))))) | |
1767 | ("googletest" ,googletest) | |
1768 | ("swig" ,swig) | |
1769 | ("unzip" ,unzip))) | |
1770 | (propagated-inputs | |
1771 | `(("python-absl-py" ,python-absl-py) | |
1772 | ("python-astor" ,python-astor) | |
1773 | ("python-gast" ,python-gast) | |
1774 | ("python-grpcio" ,python-grpcio) | |
1775 | ("python-numpy" ,python-numpy) | |
7373eb83 | 1776 | ("python-protobuf" ,python-protobuf-3.6) |
4fa16c9a RW |
1777 | ("python-six" ,python-six) |
1778 | ("python-termcolo" ,python-termcolor) | |
1779 | ("python-wheel" ,python-wheel))) | |
1780 | (inputs | |
3b458d54 | 1781 | `(("c-ares" ,c-ares) |
4fa16c9a RW |
1782 | ("eigen" ,eigen-for-tensorflow) |
1783 | ("gemmlowp" ,gemmlowp-for-tensorflow) | |
1784 | ("lmdb" ,lmdb) | |
4bd428a7 | 1785 | ("libjpeg" ,libjpeg-turbo) |
4fa16c9a RW |
1786 | ("libpng" ,libpng) |
1787 | ("giflib" ,giflib) | |
80a8583a | 1788 | ("grpc" ,grpc-1.16.1 "static") |
447fafe3 | 1789 | ("grpc:bin" ,grpc-1.16.1) |
4fa16c9a RW |
1790 | ("jsoncpp" ,jsoncpp-for-tensorflow) |
1791 | ("snappy" ,snappy) | |
1792 | ("sqlite" ,sqlite) | |
7373eb83 | 1793 | ("protobuf" ,protobuf-3.6) |
4fa16c9a RW |
1794 | ("python" ,python-wrapper) |
1795 | ("zlib" ,zlib))) | |
1796 | (home-page "https://tensorflow.org") | |
1797 | (synopsis "Machine learning framework") | |
1798 | (description | |
1799 | "TensorFlow is a flexible platform for building and training machine | |
1800 | learning models. It provides a library for high performance numerical | |
1801 | computation and includes high level Python APIs, including both a sequential | |
1802 | API for beginners that allows users to build models quickly by plugging | |
1803 | together building blocks and a subclassing API with an imperative style for | |
1804 | advanced research.") | |
1805 | (license license:asl2.0))) | |
d60b064d NG |
1806 | |
1807 | (define-public python-iml | |
1808 | (package | |
1809 | (name "python-iml") | |
1810 | (version "0.6.2") | |
1811 | (source | |
1812 | (origin | |
1813 | (method url-fetch) | |
1814 | (uri (pypi-uri "iml" version)) | |
1815 | (sha256 | |
1816 | (base32 | |
1817 | "1k8szlpm19rcwcxdny9qdm3gmaqq8akb4xlvrzyz8c2d679aak6l")))) | |
1818 | (build-system python-build-system) | |
1819 | (propagated-inputs | |
32ba87c1 EK |
1820 | `(("ipython" ,(prompt-toolkit-2-instead-of-prompt-toolkit |
1821 | python-ipython)) | |
d60b064d NG |
1822 | ("numpy" ,python-numpy) |
1823 | ("pandas" ,python-pandas) | |
1824 | ("scipy" ,python-scipy))) | |
bcbd6340 EK |
1825 | (native-inputs |
1826 | `(("nose" ,python-nose))) | |
dd003125 | 1827 | (home-page "https://github.com/interpretable-ml/iml") |
d60b064d NG |
1828 | (synopsis "Interpretable Machine Learning (iML) package") |
1829 | (description "Interpretable ML (iML) is a set of data type objects, | |
1830 | visualizations, and interfaces that can be used by any method designed to | |
1831 | explain the predictions of machine learning models (or really the output of | |
1832 | any function). It currently contains the interface and IO code from the Shap | |
1833 | project, and it will potentially also do the same for the Lime project.") | |
1834 | (license license:expat))) | |
d93ad191 RW |
1835 | |
1836 | (define-public python-keras-applications | |
1837 | (package | |
1838 | (name "python-keras-applications") | |
1839 | (version "1.0.8") | |
1840 | (source | |
1841 | (origin | |
1842 | (method url-fetch) | |
1843 | (uri (pypi-uri "Keras_Applications" version)) | |
1844 | (sha256 | |
1845 | (base32 | |
1846 | "1rcz31ca4axa6kzhjx4lwqxbg4wvlljkj8qj9a7p9sfd5fhzjyam")))) | |
1847 | (build-system python-build-system) | |
1848 | ;; The tests require Keras, but this package is needed to build Keras. | |
1849 | (arguments '(#:tests? #f)) | |
1850 | (propagated-inputs | |
1851 | `(("python-h5py" ,python-h5py) | |
1852 | ("python-numpy" ,python-numpy))) | |
1853 | (native-inputs | |
1854 | `(("python-pytest" ,python-pytest) | |
1855 | ("python-pytest-cov" ,python-pytest-cov) | |
1856 | ("python-pytest-pep8" ,python-pytest-pep8) | |
1857 | ("python-pytest-xdist" ,python-pytest-xdist))) | |
1858 | (home-page "https://github.com/keras-team/keras-applications") | |
1859 | (synopsis "Reference implementations of popular deep learning models") | |
1860 | (description | |
1861 | "This package provides reference implementations of popular deep learning | |
1862 | models for use with the Keras deep learning framework.") | |
1863 | (license license:expat))) | |
4abc5066 RW |
1864 | |
1865 | (define-public python-keras-preprocessing | |
1866 | (package | |
1867 | (name "python-keras-preprocessing") | |
1868 | (version "1.1.0") | |
1869 | (source | |
1870 | (origin | |
1871 | (method url-fetch) | |
1872 | (uri (pypi-uri "Keras_Preprocessing" version)) | |
1873 | (sha256 | |
1874 | (base32 | |
1875 | "1r98nm4k1svsqjyaqkfk23i31bl1kcfcyp7094yyj3c43phfp3as")))) | |
1876 | (build-system python-build-system) | |
1877 | (propagated-inputs | |
1878 | `(("python-numpy" ,python-numpy) | |
1879 | ("python-six" ,python-six))) | |
1880 | (native-inputs | |
1881 | `(("python-pandas" ,python-pandas) | |
1882 | ("python-pillow" ,python-pillow) | |
1883 | ("python-pytest" ,python-pytest) | |
1884 | ("python-pytest-cov" ,python-pytest-cov) | |
1885 | ("python-pytest-xdist" ,python-pytest-xdist) | |
1886 | ("tensorflow" ,tensorflow))) | |
1887 | (home-page "https://github.com/keras-team/keras-preprocessing/") | |
1888 | (synopsis "Data preprocessing and augmentation for deep learning models") | |
1889 | (description | |
1890 | "Keras Preprocessing is the data preprocessing and data augmentation | |
1891 | module of the Keras deep learning library. It provides utilities for working | |
1892 | with image data, text data, and sequence data.") | |
1893 | (license license:expat))) | |
f1765b57 RW |
1894 | |
1895 | (define-public python-keras | |
1896 | (package | |
1897 | (name "python-keras") | |
1898 | (version "2.2.4") | |
1899 | (source | |
1900 | (origin | |
1901 | (method url-fetch) | |
1902 | (uri (pypi-uri "Keras" version)) | |
b16e0827 | 1903 | (patches (search-patches "python-keras-integration-test.patch")) |
f1765b57 RW |
1904 | (sha256 |
1905 | (base32 | |
1906 | "1j8bsqzh49vjdxy6l1k4iwax5vpjzniynyd041xjavdzvfii1dlh")))) | |
1907 | (build-system python-build-system) | |
1908 | (arguments | |
1909 | `(#:phases | |
1910 | (modify-phases %standard-phases | |
1911 | (add-after 'unpack 'remove-tests-for-unavailable-features | |
1912 | (lambda _ | |
1913 | (delete-file "keras/backend/theano_backend.py") | |
1914 | (delete-file "keras/backend/cntk_backend.py") | |
1915 | (delete-file "tests/keras/backend/backend_test.py") | |
1916 | ||
1917 | ;; FIXME: This doesn't work because Tensorflow is missing the | |
1918 | ;; coder ops library. | |
1919 | (delete-file "tests/keras/test_callbacks.py") | |
1920 | #t)) | |
1921 | (replace 'check | |
1922 | (lambda _ | |
1923 | ;; These tests attempt to download data files from the internet. | |
1924 | (delete-file "tests/integration_tests/test_datasets.py") | |
1925 | (delete-file "tests/integration_tests/imagenet_utils_test.py") | |
1926 | ||
1927 | (setenv "PYTHONPATH" | |
1928 | (string-append (getcwd) "/build/lib:" | |
1929 | (getenv "PYTHONPATH"))) | |
1930 | (invoke "py.test" "-v" | |
1931 | "-p" "no:cacheprovider" | |
1932 | "--ignore" "keras/utils")))))) | |
1933 | (propagated-inputs | |
1934 | `(("python-h5py" ,python-h5py) | |
1935 | ("python-keras-applications" ,python-keras-applications) | |
1936 | ("python-keras-preprocessing" ,python-keras-preprocessing) | |
1937 | ("python-numpy" ,python-numpy) | |
1938 | ("python-pydot" ,python-pydot) | |
1939 | ("python-pyyaml" ,python-pyyaml) | |
1940 | ("python-scipy" ,python-scipy) | |
1941 | ("python-six" ,python-six) | |
1942 | ("tensorflow" ,tensorflow) | |
1943 | ("graphviz" ,graphviz))) | |
1944 | (native-inputs | |
1945 | `(("python-pandas" ,python-pandas) | |
1946 | ("python-pytest" ,python-pytest) | |
1947 | ("python-pytest-cov" ,python-pytest-cov) | |
1948 | ("python-pytest-pep8" ,python-pytest-pep8) | |
1949 | ("python-pytest-timeout" ,python-pytest-timeout) | |
1950 | ("python-pytest-xdist" ,python-pytest-xdist) | |
1951 | ("python-sphinx" ,python-sphinx) | |
1952 | ("python-requests" ,python-requests))) | |
1953 | (home-page "https://github.com/keras-team/keras") | |
1954 | (synopsis "High-level deep learning framework") | |
1955 | (description "Keras is a high-level neural networks API, written in Python | |
1956 | and capable of running on top of TensorFlow. It was developed with a focus on | |
1957 | enabling fast experimentation. Use Keras if you need a deep learning library | |
1958 | that: | |
1959 | ||
1960 | @itemize | |
1961 | @item Allows for easy and fast prototyping (through user friendliness, | |
1962 | modularity, and extensibility). | |
1963 | @item Supports both convolutional networks and recurrent networks, as well as | |
1964 | combinations of the two. | |
1965 | @item Runs seamlessly on CPU and GPU. | |
1966 | @end itemize\n") | |
1967 | (license license:expat))) | |
6e760872 GLV |
1968 | |
1969 | (define-public sbcl-cl-libsvm-format | |
1970 | (let ((commit "3300f84fd8d9f5beafc114f543f9d83417c742fb") | |
1971 | (revision "0")) | |
1972 | (package | |
1973 | (name "sbcl-cl-libsvm-format") | |
1974 | (version (git-version "0.1.0" revision commit)) | |
1975 | (source | |
1976 | (origin | |
1977 | (method git-fetch) | |
1978 | (uri (git-reference | |
1979 | (url "https://github.com/masatoi/cl-libsvm-format.git") | |
1980 | (commit commit))) | |
1981 | (file-name (git-file-name name version)) | |
1982 | (sha256 | |
1983 | (base32 | |
1984 | "0284aj84xszhkhlivaigf9qj855fxad3mzmv3zfr0qzb5k0nzwrg")))) | |
1985 | (build-system asdf-build-system/sbcl) | |
1986 | (native-inputs | |
1987 | `(("prove" ,sbcl-prove) | |
1988 | ("prove-asdf" ,sbcl-prove-asdf))) | |
1989 | (inputs | |
1990 | `(("alexandria" ,sbcl-alexandria))) | |
1991 | (synopsis "LibSVM data format reader for Common Lisp") | |
1992 | (description | |
1993 | "This Common Lisp library provides a fast reader for data in LibSVM | |
1994 | format.") | |
1995 | (home-page "https://github.com/masatoi/cl-libsvm-format") | |
1996 | (license license:expat)))) | |
1997 | ||
1998 | (define-public cl-libsvm-format | |
1999 | (sbcl-package->cl-source-package sbcl-cl-libsvm-format)) | |
2000 | ||
2001 | (define-public ecl-cl-libsvm-format | |
2002 | (sbcl-package->ecl-package sbcl-cl-libsvm-format)) | |
7a15aab8 GLV |
2003 | |
2004 | (define-public sbcl-cl-online-learning | |
2005 | (let ((commit "fc7a34f4f161cd1c7dd747d2ed8f698947781423") | |
2006 | (revision "0")) | |
2007 | (package | |
2008 | (name "sbcl-cl-online-learning") | |
2009 | (version (git-version "0.5" revision commit)) | |
2010 | (source | |
2011 | (origin | |
2012 | (method git-fetch) | |
2013 | (uri (git-reference | |
2014 | (url "https://github.com/masatoi/cl-online-learning.git") | |
2015 | (commit commit))) | |
2016 | (file-name (git-file-name name version)) | |
2017 | (sha256 | |
2018 | (base32 | |
2019 | "14x95rlg80ay5hv645ki57pqvy12v28hz4k1w0f6bsfi2rmpxchq")))) | |
2020 | (build-system asdf-build-system/sbcl) | |
2021 | (native-inputs | |
2022 | `(("prove" ,sbcl-prove) | |
2023 | ("prove-asdf" ,sbcl-prove-asdf))) | |
2024 | (inputs | |
2025 | `(("cl-libsvm-format" ,sbcl-cl-libsvm-format) | |
2026 | ("cl-store" ,sbcl-cl-store))) | |
2027 | (arguments | |
2028 | `(;; FIXME: Tests pass but then the check phase crashes | |
2029 | #:tests? #f)) | |
2030 | (synopsis "Online Machine Learning for Common Lisp") | |
2031 | (description | |
2032 | "This library contains a collection of machine learning algorithms for | |
2033 | online linear classification written in Common Lisp.") | |
2034 | (home-page "https://github.com/masatoi/cl-online-learning") | |
2035 | (license license:expat)))) | |
2036 | ||
2037 | (define-public cl-online-learning | |
2038 | (sbcl-package->cl-source-package sbcl-cl-online-learning)) | |
2039 | ||
2040 | (define-public ecl-cl-online-learning | |
2041 | (sbcl-package->ecl-package sbcl-cl-online-learning)) | |
5a65fede GLV |
2042 | |
2043 | (define-public sbcl-cl-random-forest | |
2044 | (let ((commit "85fbdd4596d40e824f70f1b7cf239cf544e49d51") | |
2045 | (revision "0")) | |
2046 | (package | |
2047 | (name "sbcl-cl-random-forest") | |
2048 | (version (git-version "0.1" revision commit)) | |
2049 | (source | |
2050 | (origin | |
2051 | (method git-fetch) | |
2052 | (uri (git-reference | |
2053 | (url "https://github.com/masatoi/cl-random-forest.git") | |
2054 | (commit commit))) | |
2055 | (file-name (git-file-name name version)) | |
2056 | (sha256 | |
2057 | (base32 | |
2058 | "097xv60i1ndz68sg9p4pc7c5gvyp9i1xgw966b4wwfq3x6hbz421")))) | |
2059 | (build-system asdf-build-system/sbcl) | |
2060 | (native-inputs | |
2061 | `(("prove" ,sbcl-prove) | |
2062 | ("prove-asdf" ,sbcl-prove-asdf) | |
2063 | ("trivial-garbage" ,sbcl-trivial-garbage))) | |
2064 | (inputs | |
2065 | `(("alexandria" ,sbcl-alexandria) | |
2066 | ("cl-libsvm-format" ,sbcl-cl-libsvm-format) | |
2067 | ("cl-online-learning" ,sbcl-cl-online-learning) | |
2068 | ("lparallel" ,sbcl-lparallel))) | |
2069 | (arguments | |
5dc04da4 | 2070 | `(#:tests? #f)) ; The tests download data from the Internet |
5a65fede GLV |
2071 | (synopsis "Random Forest and Global Refinement for Common Lisp") |
2072 | (description | |
2073 | "CL-random-forest is an implementation of Random Forest for multiclass | |
2074 | classification and univariate regression written in Common Lisp. It also | |
2075 | includes an implementation of Global Refinement of Random Forest.") | |
2076 | (home-page "https://github.com/masatoi/cl-random-forest") | |
2077 | (license license:expat)))) | |
2078 | ||
2079 | (define-public cl-random-forest | |
2080 | (sbcl-package->cl-source-package sbcl-cl-random-forest)) | |
2081 | ||
2082 | (define-public ecl-cl-random-forest | |
2083 | (sbcl-package->ecl-package sbcl-cl-random-forest)) | |
58b13287 GL |
2084 | |
2085 | (define-public gloo | |
2086 | (let ((version "0.0.0") ; no proper version tag | |
2087 | (commit "ca528e32fea9ca8f2b16053cff17160290fc84ce") | |
2088 | (revision "0")) | |
2089 | (package | |
2090 | (name "gloo") | |
2091 | (version (git-version version revision commit)) | |
2092 | (source | |
2093 | (origin | |
2094 | (method git-fetch) | |
2095 | (uri (git-reference | |
2096 | (url "https://github.com/facebookincubator/gloo.git") | |
2097 | (commit commit))) | |
2098 | (file-name (git-file-name name version)) | |
2099 | (sha256 | |
2100 | (base32 | |
2101 | "1q9f80zy75f6njrzrqkmhc0g3qxs4gskr7ns2jdqanxa2ww7a99w")))) | |
2102 | (build-system cmake-build-system) | |
2103 | (native-inputs | |
2104 | `(("googletest" ,googletest))) | |
2105 | (arguments | |
2106 | `(#:configure-flags '("-DBUILD_TEST=1") | |
2107 | #:phases | |
2108 | (modify-phases %standard-phases | |
2109 | (replace 'check | |
2110 | (lambda _ | |
2111 | (invoke "make" "gloo_test") | |
2112 | #t))))) | |
2113 | (synopsis "Collective communications library") | |
2114 | (description | |
2115 | "Gloo is a collective communications library. It comes with a | |
2116 | number of collective algorithms useful for machine learning applications. | |
2117 | These include a barrier, broadcast, and allreduce.") | |
2118 | (home-page "https://github.com/facebookincubator/gloo") | |
2119 | (license license:bsd-3)))) | |
5e42d197 BG |
2120 | |
2121 | (define-public python-umap-learn | |
2122 | (package | |
2123 | (name "python-umap-learn") | |
2124 | (version "0.3.10") | |
2125 | (source | |
2126 | (origin | |
2127 | (method url-fetch) | |
2128 | (uri (pypi-uri "umap-learn" version)) | |
2129 | (sha256 | |
2130 | (base32 | |
2131 | "02ada2yy6km6zgk2836kg1c97yrcpalvan34p8c57446finnpki1")))) | |
2132 | (build-system python-build-system) | |
2133 | (native-inputs | |
e2ca10a4 RJ |
2134 | `(("python-joblib" ,python-joblib) |
2135 | ("python-nose" ,python-nose))) | |
5e42d197 BG |
2136 | (propagated-inputs |
2137 | `(("python-numba" ,python-numba) | |
2138 | ("python-numpy" ,python-numpy) | |
2139 | ("python-scikit-learn" ,python-scikit-learn) | |
2140 | ("python-scipy" ,python-scipy))) | |
2141 | (home-page "https://github.com/lmcinnes/umap") | |
2142 | (synopsis | |
2143 | "Uniform Manifold Approximation and Projection") | |
2144 | (description | |
2145 | "Uniform Manifold Approximation and Projection is a dimension reduction | |
2146 | technique that can be used for visualisation similarly to t-SNE, but also for | |
2147 | general non-linear dimension reduction.") | |
2148 | (license license:bsd-3))) |