From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2.migadu.com ([2001:41d0:403:58f0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms8.migadu.com with LMTPS id 0L/hBj/QBmaqdwAAe85BDQ:P1 (envelope-from ) for ; Fri, 29 Mar 2024 15:29:19 +0100 Received: from aspmx1.migadu.com ([2001:41d0:403:58f0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2.migadu.com with LMTPS id 0L/hBj/QBmaqdwAAe85BDQ (envelope-from ) for ; Fri, 29 Mar 2024 15:29:19 +0100 X-Envelope-To: larch@yhetil.org Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=TWqhA9P8; spf=pass (aspmx1.migadu.com: domain of "help-guix-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="help-guix-bounces+larch=yhetil.org@gnu.org"; dmarc=pass (policy=none) header.from=gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1711722558; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:list-id:list-help: list-unsubscribe:list-subscribe:list-post:dkim-signature; bh=jaTs/pWekdixIOaMm3YCP37aAowUW4nCuEnH65CuzYE=; b=HPxUR/bJTI3wgYaV5w4UsZbMbFRWLW5Xm7MzO1eFjslRdKwciFWUrcV9JR3cXWg8m4MYon oIiH4Fj4At+qWmvcFQH+tPAeY3PmGqCABZYy2wz84Yjxp1I9jiRCYOMmPkq3ZHW76S15bu jz5B+5TJ+11aHfItxirMIbnjhbi0srNF9YcywNL+SCVQRx6Mk5hvQwpLs11ekshksx7cSw r4JqwXrAI1kzCwq863tZSXmJ90IfjLs9RPiYu1+QbCqLgQpD7/T9wh2Vb6ZWJfJzX/DVha 81KlUZksnMm69vVRxtHyltUa4qzYPX681pf7MjC4qbnd3lUzZU1BT4aeW9e5yA== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=TWqhA9P8; spf=pass (aspmx1.migadu.com: domain of "help-guix-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="help-guix-bounces+larch=yhetil.org@gnu.org"; dmarc=pass (policy=none) header.from=gmail.com ARC-Seal: i=1; s=key1; d=yhetil.org; t=1711722558; a=rsa-sha256; cv=none; b=AoaJjDhO4aFY2nRDQr6rVTMJrl//0mPbagSgvWNCAKRRQw2PYrBXqlCog0B5rS2/6wXNXk psyiiemfmAr/h7HUewmvcZWR+kDGbyNOwrpX7YHBmNBojfGEjEZYXlcNAvUhwJf65cAppG bpnl1brWfEO9kpmVigxZgFI4dlenTFZYq6CWCMSS+FEPctiZD5cWDCC26UDQsRnWgXsiMM oTG7wNixf2HZVO/Cu4SSDUf0tq8rqQm4dzwqBt8qlwGKfquXeSFNsBkFGrASOHJyqYcvqV pZ70TW37jgbOMbQhZb6miheKtub5VCMJYJirY6ljhSBwPVzwh0/LSsvWyf6ZSg== Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id B7B3738144 for ; Fri, 29 Mar 2024 15:29:18 +0100 (CET) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rqDE1-0001N9-TO; Fri, 29 Mar 2024 10:28:57 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rqDE0-0001MA-Et for help-guix@gnu.org; Fri, 29 Mar 2024 10:28:56 -0400 Received: from mail-wr1-x432.google.com ([2a00:1450:4864:20::432]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rqDDy-000404-C5 for help-guix@gnu.org; Fri, 29 Mar 2024 10:28:56 -0400 Received: by mail-wr1-x432.google.com with SMTP id ffacd0b85a97d-341bba83366so484801f8f.1 for ; Fri, 29 Mar 2024 07:28:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1711722532; x=1712327332; darn=gnu.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=jaTs/pWekdixIOaMm3YCP37aAowUW4nCuEnH65CuzYE=; b=TWqhA9P8RlU/jPrLKi7XLroNYufvmaduOC5lHbe7RpOkKhZGSXNibStd39ogBQL2u1 wwIHmDQGvcmMoyMOQDOsuCnpSnNcnR3E0cRFlo+7w4rTuudjjXYCHEUqKeqC9rnsHCmm BQwI0fahBGgxU4EoKsGMfSA3uXcVp9z5axgzQO2B9Ll2aicsJQSNJabcw5RUauHv8wKC bZDKDjFZrrnw3f1+14xIShj8oMVxwpK+3YL0RnIsVGJxDxDxuf0S2adNyx0Vmw0oDVJH oGK92OSq1xhzDRXwguAmHqUJbPFeHWjfXSJctZPZww8u8l7aephxY6A/MT+7eJ+/8mCL qjvw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711722532; x=1712327332; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=jaTs/pWekdixIOaMm3YCP37aAowUW4nCuEnH65CuzYE=; b=DvL3MAWzg/A7D9Ys8zOSCGWstzEf3wOAsUlsJtsZ/9qzQGE/QLD0hs0i3ulybAsu0H 6jydvLJUMKUJtYK5nXqPJDrlw7cxx36uVSZnl4VsMgQLAa4wYwzF3uV4+JWLp4lJnidm 8oRPR9h2iMp2Ydq3DymjlYk8Pq7GLuEXCvFaiiRlBGAIfuddDZ8wRc+2vB8hSsjPn5xB NMMux9f+zB/Y3v7J9c4vW/SLpg7J3ZWF1fVSttogkn4wOddCXKPxrALL6hpgXO/9YuHx R8wfRWnkpzpz5ECXr4N83j8qy6+ARnYhAbIazS9i+Uq1f47B8RWK+h6scSVqrzd52f05 MMNA== X-Gm-Message-State: AOJu0YzpS7+3M5vMl2w5uGn0ncuSqPvnXyyKTefO5JgIse7eOQw6Q1dS BgsNNj2QeQ4iDSCSeqocT81m4QfR0i8AJ7waV37BJnkPO1wE8o7ocu9D161Z X-Google-Smtp-Source: AGHT+IHPFeyW9jBhbREHKSgYwmtVWnP2BEHWqQYGXhW/7Q9KT+fSdkuEYc5vko75Vz+ptg6n3VO05w== X-Received: by 2002:a05:6000:186a:b0:343:3cf0:c7bd with SMTP id d10-20020a056000186a00b003433cf0c7bdmr890444wri.5.1711722531999; Fri, 29 Mar 2024 07:28:51 -0700 (PDT) Received: from pfiuh07 ([193.48.40.241]) by smtp.gmail.com with ESMTPSA id b16-20020a5d6350000000b0033e7715bafasm4331848wrw.59.2024.03.29.07.28.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Mar 2024 07:28:51 -0700 (PDT) From: Simon Tournier To: help-guix@gnu.org Cc: Ricardo Wurmus , QUENTIN Samuel Subject: how to use r-keras? Date: Fri, 29 Mar 2024 15:28:49 +0100 Message-ID: <87y1a15cym.fsf@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Received-SPF: pass client-ip=2a00:1450:4864:20::432; envelope-from=zimon.toutoune@gmail.com; helo=mail-wr1-x432.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: help-guix@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-guix-bounces+larch=yhetil.org@gnu.org Sender: help-guix-bounces+larch=yhetil.org@gnu.org X-Migadu-Flow: FLOW_IN X-Migadu-Country: US X-Migadu-Queue-Id: B7B3738144 X-Spam-Score: -8.64 X-Migadu-Spam-Score: -8.64 X-Migadu-Scanner: mx11.migadu.com X-TUID: 0wXPtGVaJ+Xt Hi, Trying to run =E2=80=9Cr-keras=E2=80=9D, I am a bit puzzled. --8<---------------cut here---------------start------------->8--- $ guix shell r r-keras -C python-minimal r-reticulate tensorflow --8<---------------cut here---------------end--------------->8--- Well, one needs to know some internals=E2=80=A6 --8<---------------cut here---------------start------------->8--- $ R R version 4.3.3 (2024-02-29) -- "Angel Food Cake" Copyright (C) 2024 The R Foundation for Statistical Computing Platform: x86_64-unknown-linux-gnu (64-bit) R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. > library(keras) --8<---------------cut here---------------end--------------->8--- So far, so good! Let try the tutorial [1]. Then my first =E2=80=9Csurprise=E2=80=9D: --8<---------------cut here---------------start------------->8--- > model <- keras_model_sequential() Would you like to create a default python environment for the reticulate pa= ckage? (Yes/no/cancel) no --8<---------------cut here---------------end--------------->8--- which leads to this unexpected message: --8<---------------cut here---------------start------------->8--- /gnu/store/134bswprchk6rp3f5pskva3dq0j8gycp-profile/lib/python3.10/site-pac= kages/tensorflow/python/framework/dtypes.py:523: FutureWarning: Passing (ty= pe, 1) or '1type' as a synonym of type is deprecated; in a future version o= f numpy, it will be understood as (type, (1,)) / '(1,)type'. _np_qint8 =3D np.dtype([("qint8", np.int8, 1)]) /gnu/store/134bswprchk6rp3f5pskva3dq0j8gycp-profile/lib/python3.10/site-pac= kages/tensorflow/python/framework/dtypes.py:524: FutureWarning: Passing (ty= pe, 1) or '1type' as a synonym of type is deprecated; in a future version o= f numpy, it will be understood as (type, (1,)) / '(1,)type'. _np_quint8 =3D np.dtype([("quint8", np.uint8, 1)]) /gnu/store/134bswprchk6rp3f5pskva3dq0j8gycp-profile/lib/python3.10/site-pac= kages/tensorflow/python/framework/dtypes.py:525: FutureWarning: Passing (ty= pe, 1) or '1type' as a synonym of type is deprecated; in a future version o= f numpy, it will be understood as (type, (1,)) / '(1,)type'. _np_qint16 =3D np.dtype([("qint16", np.int16, 1)]) /gnu/store/134bswprchk6rp3f5pskva3dq0j8gycp-profile/lib/python3.10/site-pac= kages/tensorflow/python/framework/dtypes.py:526: FutureWarning: Passing (ty= pe, 1) or '1type' as a synonym of type is deprecated; in a future version o= f numpy, it will be understood as (type, (1,)) / '(1,)type'. _np_quint16 =3D np.dtype([("quint16", np.uint16, 1)]) /gnu/store/134bswprchk6rp3f5pskva3dq0j8gycp-profile/lib/python3.10/site-pac= kages/tensorflow/python/framework/dtypes.py:527: FutureWarning: Passing (ty= pe, 1) or '1type' as a synonym of type is deprecated; in a future version o= f numpy, it will be understood as (type, (1,)) / '(1,)type'. _np_qint32 =3D np.dtype([("qint32", np.int32, 1)]) /gnu/store/134bswprchk6rp3f5pskva3dq0j8gycp-profile/lib/python3.10/site-pac= kages/tensorflow/python/framework/dtypes.py:532: FutureWarning: Passing (ty= pe, 1) or '1type' as a synonym of type is deprecated; in a future version o= f numpy, it will be understood as (type, (1,)) / '(1,)type'. np_resource =3D np.dtype([("resource", np.ubyte, 1)]) --8<---------------cut here---------------end--------------->8--- Ok, let create a model: --8<---------------cut here---------------start------------->8--- > model %>% # Adds a densely-connected layer with 64 units to the model: layer_dense(units =3D 64, activation =3D 'relu') %>% # Add another: layer_dense(units =3D 64, activation =3D 'relu') %>% # Add a softmax layer with 10 output units: layer_dense(units =3D 10, activation =3D 'softmax') > + + + + + + + + + >=20 > model %>% compile( optimizer =3D 'adam', loss =3D 'categorical_crossentropy', metrics =3D list('accuracy') ) + + + + >=20 --8<---------------cut here---------------end--------------->8--- So far, so good! Now, let train the model: --8<---------------cut here---------------start------------->8--- > data <- matrix(rnorm(1000 * 32), nrow =3D 1000, ncol =3D 32) labels <- matrix(rnorm(1000 * 10), nrow =3D 1000, ncol =3D 10) model %>% fit( data, labels, epochs =3D 10, batch_size =3D 32 ) > > > + + + + + Error in py_get_attr_impl(x, name, silent) :=20 AttributeError: module 'kerastools' has no attribute 'callback' Run `reticulate::py_last_error()` for details. --8<---------------cut here---------------end--------------->8--- And this error reads: --8<---------------cut here---------------start------------->8--- > reticulate::py_last_error() -- Python Exception Message -----------------------------------------------= ----- AttributeError: module 'kerastools' has no attribute 'callback' -- R Traceback ------------------------------------------------------------= ----- x 1. +-model %>% fit(data, labels, epochs =3D 10, batch_size =3D 32) 2. +-generics::fit(., data, labels, epochs =3D 10, batch_size =3D 32) 3. \-keras:::fit.keras.engine.training.Model(...) 4. \-keras:::normalize_callbacks_with_metrics(...) 5. \-keras:::normalize_callbacks(callbacks) 6. \-base::lapply(...) 7. \-keras (local) FUN(X[[i]], ...) 8. +-base::do.call(tools$callback$RCallback, args) 9. +-tools$callback 10. \-reticulate:::`$.python.builtin.module`(tools, "callback") 11. \-reticulate:::`$.python.builtin.object`(x, name) 12. \-reticulate:::py_get_attr_or_item(x, name, TRUE) 13. \-reticulate::py_get_attr(x, name) 14. \-reticulate:::py_get_attr_impl(x, name, silent) --8<---------------cut here---------------end--------------->8--- Hum? My second surprise. Any idea how to run Keras from R? Cheers, simon 1: https://tensorflow.rstudio.com/guides/keras/basics.html