PaddlePaddle supports quick installation by pip. Execute the following commands to finish quick installation of the CPU version:
.. code-block:: bash
pip install paddlepaddle
If you need to install the GPU version, or look up more specific installation methods, please refer to `Installation Instructions <../beginners_guide/install/index_en.html>`_
Quick Usage
-------------
First, you need to import the fluid library
.. code-block:: python
import paddle.fluid as fluid
* Tensor Operations
The following simple examples may help you quickly know about Fluid:
1.use Fluid to create a one-dimensional array with five elements, and each element is 1
.. code-block:: python
# define the dimension of an array and the data type, and the parameter 'shape' can be modified to define an array of any size
data = fluid.layers.ones(shape=[5], dtype='int64')
By the simple example above, you may have known how to operate data with Fluid to some extent, so please try to create a test.py, and copy the following codes.
This a a simple linear regression model to help us quickly solve the quaternary linear equation.
.. code-block:: python
#load the library
import paddle.fluid as fluid
import numpy as np
#generate data
np.random.seed(0)
outputs = np.random.randint(5, size=(10, 4))
res = []
for i in range(10):
# assume the equation is y=4a+6b+7c+2d
y = 4*outputs[i][0]+6*outputs[i][1]+7*outputs[i][2]+2*outputs[i][3]
res.append([y])
# define data
train_data=np.array(outputs).astype('float32')
y_true = np.array(res).astype('float32')
#define the network
x = fluid.layers.data(name="x",shape=[4],dtype='float32')
y = fluid.layers.data(name="y",shape=[1],dtype='float32')