Search code examples
pythonmachine-learningtheanosage

How to install Theano library using sageMath locally?


I want to know steps of installing Theano library using SageMath?


Solution

  • Just install theano using pip by running this in the terminal.

    $ sage -pip install theano
    

    Next time you run Sage, theano is available.

    sage: from theano import *
    sage: import theano.tensor as T
    sage: from theano import function
    sage: x = T.dscalar('x')
    sage: y = T.dscalar('y')
    sage: z = x + y
    sage: f = function([x, y], z)
    sage: f(2, 3)
    array(5.0)
    sage: numpy.allclose(f(16.3, 12.1), 28.4)
    True
    sage: type(x)
    <class 'theano.tensor.var.TensorVariable'>