diff --git a/01.fit_a_line/README.cn.md b/01.fit_a_line/README.cn.md index e95337d76003269caa27786500e32b91e3a53a21..ae935f2f67e1f1e4a88efe7539575255975d969b 100644 --- a/01.fit_a_line/README.cn.md +++ b/01.fit_a_line/README.cn.md @@ -154,30 +154,23 @@ test_reader = paddle.batch( batch_size=BATCH_SIZE) ``` -如果想直接从txt文件中读取数据的话,可以参考以下方式。 - +如果想直接从txt文件中读取数据的话,可以参考以下方式(需要自行准备txt文件)。 +```text feature_names = [ 'CRIM', 'ZN', 'INDUS', 'CHAS', 'NOX', 'RM', 'AGE', 'DIS', 'RAD', 'TAX', 'PTRATIO', 'B', 'LSTAT', 'convert' ] - feature_num = len(feature_names) - data = numpy.fromfile(filename, sep=' ') # 从文件中读取原始数据 - data = data.reshape(data.shape[0] // feature_num, feature_num) - maximums, minimums, avgs = data.max(axis=0), data.min(axis=0), data.sum(axis=0)/data.shape[0] for i in six.moves.range(feature_num-1): - data[:, i] = (data[:, i] - avgs[i]) / (maximums[i] - minimums[i]) # six.moves可以兼容python2和python3 + data[:, i] = (data[:, i] - avgs[i]) / (maximums[i] - minimums[i]) # six.moves可以兼容python2和python3 ratio = 0.8 # 训练集和验证集的划分比例 - offset = int(data.shape[0]*ratio) - train_data = data[:offset] - test_data = data[offset:] def reader(data): @@ -193,6 +186,7 @@ test_reader = paddle.batch( paddle.reader.shuffle( reader(test_data), buf_size=500), batch_size=BATCH_SIZE) +``` ### 配置训练程序 训练程序的目的是定义一个训练模型的网络结构。对于线性回归来讲,它就是一个从输入到输出的简单的全连接层。更加复杂的结果,比如卷积神经网络,递归神经网络等会在随后的章节中介绍。训练程序必须返回`平均损失`作为第一个返回值,因为它会被后面反向传播算法所用到。 diff --git a/01.fit_a_line/README.md b/01.fit_a_line/README.md index f8a6e8ee27dbff873f907776d824db26e5512167..7bdb903cabadfcfbb81609a2669eafb1c112102f 100644 --- a/01.fit_a_line/README.md +++ b/01.fit_a_line/README.md @@ -156,30 +156,23 @@ test_reader = paddle.batch( batch_size=BATCH_SIZE) ``` -If you want to read data directly from \*.txt file, you can refer to the method as follows. - +If you want to read data directly from \*.txt file, you can refer to the method as follows(need to prepare txt file by yourself). +```text feature_names = [ 'CRIM', 'ZN', 'INDUS', 'CHAS', 'NOX', 'RM', 'AGE', 'DIS', 'RAD', 'TAX', 'PTRATIO', 'B', 'LSTAT', 'convert' ] - feature_num = len(feature_names) - data = numpy.fromfile(filename, sep=' ') # Read primary data from file - data = data.reshape(data.shape[0] // feature_num, feature_num) - maximums, minimums, avgs = data.max(axis=0), data.min(axis=0), data.sum(axis=0)/data.shape[0] for i in six.moves.range(feature_num-1): - data[:, i] = (data[:, i] - avgs[i]) / (maximums[i] - minimums[i]) # six.moves is compatible to python2 and python3 + data[:, i] = (data[:, i] - avgs[i]) / (maximums[i] - minimums[i]) # six.moves is compatible to python2 and python3 ratio = 0.8 # distribution ratio of train dataset and verification dataset - offset = int(data.shape[0]\*ratio) - train_data = data[:offset] - test_data = data[offset:] train_reader = paddle.batch( @@ -191,6 +184,7 @@ test_reader = paddle.batch( paddle.reader.shuffle( test_data, buf_size=500), batch_size=BATCH_SIZE) +``` ### Configure Program for Training The aim of the program for training is to define a network structure of a training model. For linear regression, it is a simple fully connected layer from input to output. More complex result, such as Convolutional Neural Network and Recurrent Neural Network, will be introduced in later chapters. It must return `mean error` as the first return value in program for training, for that `mean error` will be used for BackPropagation. diff --git a/01.fit_a_line/index.cn.html b/01.fit_a_line/index.cn.html index 4c99b3e552f2bbaf0751f6a1f2034232dbfd26fa..d4df07293ba5bca2dbd54694b81a6b0117b755db 100644 --- a/01.fit_a_line/index.cn.html +++ b/01.fit_a_line/index.cn.html @@ -196,30 +196,23 @@ test_reader = paddle.batch( batch_size=BATCH_SIZE) ``` -如果想直接从txt文件中读取数据的话,可以参考以下方式。 - +如果想直接从txt文件中读取数据的话,可以参考以下方式(需要自行准备txt文件)。 +```text feature_names = [ 'CRIM', 'ZN', 'INDUS', 'CHAS', 'NOX', 'RM', 'AGE', 'DIS', 'RAD', 'TAX', 'PTRATIO', 'B', 'LSTAT', 'convert' ] - feature_num = len(feature_names) - data = numpy.fromfile(filename, sep=' ') # 从文件中读取原始数据 - data = data.reshape(data.shape[0] // feature_num, feature_num) - maximums, minimums, avgs = data.max(axis=0), data.min(axis=0), data.sum(axis=0)/data.shape[0] for i in six.moves.range(feature_num-1): - data[:, i] = (data[:, i] - avgs[i]) / (maximums[i] - minimums[i]) # six.moves可以兼容python2和python3 + data[:, i] = (data[:, i] - avgs[i]) / (maximums[i] - minimums[i]) # six.moves可以兼容python2和python3 ratio = 0.8 # 训练集和验证集的划分比例 - offset = int(data.shape[0]*ratio) - train_data = data[:offset] - test_data = data[offset:] def reader(data): @@ -235,6 +228,7 @@ test_reader = paddle.batch( paddle.reader.shuffle( reader(test_data), buf_size=500), batch_size=BATCH_SIZE) +``` ### 配置训练程序 训练程序的目的是定义一个训练模型的网络结构。对于线性回归来讲,它就是一个从输入到输出的简单的全连接层。更加复杂的结果,比如卷积神经网络,递归神经网络等会在随后的章节中介绍。训练程序必须返回`平均损失`作为第一个返回值,因为它会被后面反向传播算法所用到。 diff --git a/01.fit_a_line/index.html b/01.fit_a_line/index.html index 5c29f8ed37f0159ea935da3684715ed8975e812d..0c046f0e276419d5fb51a58f42634cd02ea8464f 100644 --- a/01.fit_a_line/index.html +++ b/01.fit_a_line/index.html @@ -198,30 +198,23 @@ test_reader = paddle.batch( batch_size=BATCH_SIZE) ``` -If you want to read data directly from \*.txt file, you can refer to the method as follows. - +If you want to read data directly from \*.txt file, you can refer to the method as follows(need to prepare txt file by yourself). +```text feature_names = [ 'CRIM', 'ZN', 'INDUS', 'CHAS', 'NOX', 'RM', 'AGE', 'DIS', 'RAD', 'TAX', 'PTRATIO', 'B', 'LSTAT', 'convert' ] - feature_num = len(feature_names) - data = numpy.fromfile(filename, sep=' ') # Read primary data from file - data = data.reshape(data.shape[0] // feature_num, feature_num) - maximums, minimums, avgs = data.max(axis=0), data.min(axis=0), data.sum(axis=0)/data.shape[0] for i in six.moves.range(feature_num-1): - data[:, i] = (data[:, i] - avgs[i]) / (maximums[i] - minimums[i]) # six.moves is compatible to python2 and python3 + data[:, i] = (data[:, i] - avgs[i]) / (maximums[i] - minimums[i]) # six.moves is compatible to python2 and python3 ratio = 0.8 # distribution ratio of train dataset and verification dataset - offset = int(data.shape[0]\*ratio) - train_data = data[:offset] - test_data = data[offset:] train_reader = paddle.batch( @@ -233,6 +226,7 @@ test_reader = paddle.batch( paddle.reader.shuffle( test_data, buf_size=500), batch_size=BATCH_SIZE) +``` ### Configure Program for Training The aim of the program for training is to define a network structure of a training model. For linear regression, it is a simple fully connected layer from input to output. More complex result, such as Convolutional Neural Network and Recurrent Neural Network, will be introduced in later chapters. It must return `mean error` as the first return value in program for training, for that `mean error` will be used for BackPropagation. diff --git a/09.gan/README.cn.md b/09.gan/README.cn.md index 10266d523f8fb96ed539f69a6a703a8320d7a97d..99cf01ed570e122248a38982eeaf5b284034226a 100644 --- a/09.gan/README.cn.md +++ b/09.gan/README.cn.md @@ -162,7 +162,7 @@ def bn(x, name=None, act='relu'): - 卷积层 -调用 `fluid.nets.simple_img_conv_pool` 实现卷积池化组,卷积核大小为3x3,池化窗口大小为2x2,窗口滑动步长为2,激活函数类型由具体网络结构指定。 +调用 `fluid.nets.simple_img_conv_pool` 实现卷积池化组,卷积核大小为5x5,池化窗口大小为2x2,窗口滑动步长为2,激活函数类型由具体网络结构指定。 ```python def conv(x, num_filters, name=None, act=None): diff --git a/09.gan/index.cn.html b/09.gan/index.cn.html index ca7ee664d486e33ba84798f138df953cc2043400..8947f5a1725538fea260a17b89f57e6f028a2336 100644 --- a/09.gan/index.cn.html +++ b/09.gan/index.cn.html @@ -204,7 +204,7 @@ def bn(x, name=None, act='relu'): - 卷积层 -调用 `fluid.nets.simple_img_conv_pool` 实现卷积池化组,卷积核大小为3x3,池化窗口大小为2x2,窗口滑动步长为2,激活函数类型由具体网络结构指定。 +调用 `fluid.nets.simple_img_conv_pool` 实现卷积池化组,卷积核大小为5x5,池化窗口大小为2x2,窗口滑动步长为2,激活函数类型由具体网络结构指定。 ```python def conv(x, num_filters, name=None, act=None):