Send Beginners mailing list submissions to
        beginners@haskell.org

To subscribe or unsubscribe via the World Wide Web, visit
        http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
or, via email, send a message with subject or body 'help' to
        beginners-requ...@haskell.org

You can reach the person managing the list at
        beginners-ow...@haskell.org

When replying, please edit your Subject line so it is more specific
than "Re: Contents of Beginners digest..."


Today's Topics:

   1.  Automatic Differentiation (Jonas Béal)
   2. Re:  Automatic Differentiation (Jonas Béal)


----------------------------------------------------------------------

Message: 1
Date: Wed, 17 Aug 2016 10:40:07 +0200
From: Jonas Béal <jonas.b...@novadiscovery.com>
To: beginners@haskell.org
Subject: [Haskell-beginners] Automatic Differentiation
Message-ID:
        <CADSAVg03vEmkefkhegTWJsAdmYs--yEYN+NBfY5KRDS=hb6...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"

Hello,

I have some questions about the Automatic Differentiation package in
Haskell (https://hackage.haskell.org/package/ad-4.3.2.1/docs/Numeric-AD.html
)
I need to compute the jacobian with that method and I have a type problem,
here a simplified example in order to focus on the error:

According to documentation I need to write "*jacobian function values*". So
I built the input *function. *Please notice this is important for me that
my function may depend on an external parameter (named factor here)
testFunctionForJacobian :: Fractional a => a -> [a] -> [a]
testFunctionForJacobian factor inputs = [(sum inputs) * factor]

Then, using *jacobian* function of Numeric.AD in terminal, as a test, it
works perfectly
>jacobian (testFunctionForJacobian 2) [1,2]
< [[2.0,2.0]]

No apparent type problem here
> :t (testFunctionForJacobian 2)
(testFunctionForJacobian 2) :: Fractional a => [a] -> [a]

But, I would like to insert that in a bigger function computing the jacobian
testJacobian :: Fractional a => a -> [a] -> [[a]]
testJacobian factor inputs = jacobian (testFunctionForJacobian factor)
inputs

This time it generates an error message about *factor*
Couldn't match expected type ‘Numeric.AD.Internal.Reverse.Reverse
<http://numeric.ad.internal.reverse.reverse/> s a’ with actual type ‘a’
‘a’ is a rigid type variable bound by the type signature for
testJacobian :: Fractional a => a -> [a] -> [[a]] s a’

All in all, my type seems implicitly correct in the terminal example but I
did not manage to write it explicitly in my function.

Here the *jacobian* function signature to help you answer me:






-- 
Jonas Béal

-- 
*This message is intended only for the personal and confidential use of the 
designated recipient(s) named above. If you are not the intended recipient 
of this message you are hereby notified that any review, dissemination, 
distribution or copying of this message is strictly prohibited. Email 
transmission cannot be guaranteed to be secure or error-free. Therefore, we 
do not represent that this information is complete or accurate and it 
should not be relied upon as such. All information is subject to change 
without notice.*
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
<http://mail.haskell.org/pipermail/beginners/attachments/20160817/2806c351/attachment-0001.html>

------------------------------

Message: 2
Date: Wed, 17 Aug 2016 10:41:06 +0200
From: Jonas Béal <jonas.b...@novadiscovery.com>
To: beginners@haskell.org
Subject: Re: [Haskell-beginners] Automatic Differentiation
Message-ID:
        <cadsavg0ghy3maaw8izwinpq+0sb6xosyy9uqcdulplyeow1...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"

jacobian :: (Traversable
<https://hackage.haskell.org/package/base-4.9.0.0/docs/Data-Traversable.html#t:Traversable>
 f, Functor
<https://hackage.haskell.org/package/base-4.9.0.0/docs/Data-Functor.html#t:Functor>
 g, Num
<https://hackage.haskell.org/package/base-4.9.0.0/docs/Prelude.html#t:Num> a)
=> (forall s. Reifies
<https://hackage.haskell.org/package/reflection-2.1.2/docs/Data-Reflection.html#t:Reifies>
 s Tape
<https://hackage.haskell.org/package/ad-4.3.2.1/docs/Numeric-AD-Internal-Reverse.html#t:Tape>
=>
f (Reverse
<https://hackage.haskell.org/package/ad-4.3.2.1/docs/Numeric-AD-Mode-Reverse.html#t:Reverse>
s
a) -> g (Reverse
<https://hackage.haskell.org/package/ad-4.3.2.1/docs/Numeric-AD-Mode-Reverse.html#t:Reverse>
s
a)) -> f a -> g (f a)

 Thanks a lot for your help

Jonas BÉAL

On 17 August 2016 at 10:40, Jonas Béal <jonas.b...@novadiscovery.com> wrote:

> Hello,
>
> I have some questions about the Automatic Differentiation package in
> Haskell (https://hackage.haskell.org/package/ad-4.3.2.1/docs/Numeric
> -AD.html)
> I need to compute the jacobian with that method and I have a type problem,
> here a simplified example in order to focus on the error:
>
> According to documentation I need to write "*jacobian function values*".
> So I built the input *function. *Please notice this is important for me
> that my function may depend on an external parameter (named factor here)
> testFunctionForJacobian :: Fractional a => a -> [a] -> [a]
> testFunctionForJacobian factor inputs = [(sum inputs) * factor]
>
> Then, using *jacobian* function of Numeric.AD in terminal, as a test, it
> works perfectly
> >jacobian (testFunctionForJacobian 2) [1,2]
> < [[2.0,2.0]]
>
> No apparent type problem here
> > :t (testFunctionForJacobian 2)
> (testFunctionForJacobian 2) :: Fractional a => [a] -> [a]
>
> But, I would like to insert that in a bigger function computing the
> jacobian
> testJacobian :: Fractional a => a -> [a] -> [[a]]
> testJacobian factor inputs = jacobian (testFunctionForJacobian factor)
> inputs
>
> This time it generates an error message about *factor*
> Couldn't match expected type ‘Numeric.AD.Internal.Reverse.Reverse
> <http://numeric.ad.internal.reverse.reverse/> s a’ with actual type ‘a’
> ‘a’ is a rigid type variable bound by the type signature for
> testJacobian :: Fractional a => a -> [a] -> [[a]] s a’
>
> All in all, my type seems implicitly correct in the terminal example but I
> did not manage to write it explicitly in my function.
>
> Here the *jacobian* function signature to help you answer me:
>
>
>
>
>
>
> --
> Jonas Béal
>



-- 
Jonas Béal
R&D Scientist Intern
jonas.b...@novadiscovery.com
Novadiscovery
The Effect Model Co.
www.novadiscovery.com
+33 9 72 53 13 00
Bioparc Laënnec, 60 avenue Rockefeller, 69008 Lyon

-- 
*This message is intended only for the personal and confidential use of the 
designated recipient(s) named above. If you are not the intended recipient 
of this message you are hereby notified that any review, dissemination, 
distribution or copying of this message is strictly prohibited. Email 
transmission cannot be guaranteed to be secure or error-free. Therefore, we 
do not represent that this information is complete or accurate and it 
should not be relied upon as such. All information is subject to change 
without notice.*
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
<http://mail.haskell.org/pipermail/beginners/attachments/20160817/8be3a939/attachment.html>

------------------------------

Subject: Digest Footer

_______________________________________________
Beginners mailing list
Beginners@haskell.org
http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners


------------------------------

End of Beginners Digest, Vol 98, Issue 12
*****************************************

Reply via email to