English 中文(简体)
Theano - Variables
  • 时间:2024-12-22

Theano - Variables


Previous Page Next Page  

In the previous chapter, while discussing the data types, we created and used Theano variables. To reiterate, we would use the following syntax to create a variable in Theano −


x = theano.tensor.fvector( x )

In this statement, we have created a variable x of type vector containing 32-bit floats. We are also naming it as x. The names are generally useful for debugging.

To declare a vector of 32-bit integers, you would use the following syntax −


i32 = theano.tensor.ivector

Here, we do not specify a name for the variable.

To declare a three-dimensional vector consisting of 64-bit floats, you would use the following declaration −


f64 = theano.tensor.dtensor3

The various types of constructors along with their data types are psted in the table below −

Constructor Data type Dimensions
fvector float32 1
ivector int32 1
fscalar float32 0
fmatrix float32 2
ftensor3 float32 3
dtensor3 float64 3

You may use a generic vector constructor and specify the data type exppcitly as follows −


x = theano.tensor.vector ( x , dtype=int32)

In the next chapter, we will learn how to create shared variables.

Advertisements