Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
book
提交
9f5d2171
B
book
项目概览
PaddlePaddle
/
book
通知
16
Star
4
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
40
列表
看板
标记
里程碑
合并请求
37
Wiki
5
Wiki
分析
仓库
DevOps
项目成员
Pages
B
book
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
40
Issue
40
列表
看板
标记
里程碑
合并请求
37
合并请求
37
Pages
分析
分析
仓库分析
DevOps
Wiki
5
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
9f5d2171
编写于
9月 14, 2017
作者:
D
dzhwinter
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
config with gpu
上级
e75fd183
变更
8
显示空白变更内容
内联
并排
Showing
8 changed file
with
25 addition
and
14 deletion
+25
-14
01.fit_a_line/train.py
01.fit_a_line/train.py
+3
-1
02.recognize_digits/train.py
02.recognize_digits/train.py
+2
-1
03.image_classification/train.py
03.image_classification/train.py
+3
-2
04.word2vec/train.py
04.word2vec/train.py
+4
-2
05.recommender_system/train.py
05.recommender_system/train.py
+3
-1
06.understand_sentiment/train.py
06.understand_sentiment/train.py
+3
-2
07.label_semantic_roles/train.py
07.label_semantic_roles/train.py
+4
-2
08.machine_translation/train.py
08.machine_translation/train.py
+3
-3
未找到文件。
01.fit_a_line/train.py
浏览文件 @
9f5d2171
import
os
import
paddle.v2
as
paddle
import
paddle.v2.dataset.uci_housing
as
uci_housing
with_gpu
=
os
.
getenv
(
'WITH_GPU'
,
'0'
)
!=
'0'
def
main
():
# init
paddle
.
init
(
use_gpu
=
False
,
trainer_count
=
1
)
paddle
.
init
(
use_gpu
=
with_gpu
,
trainer_count
=
1
)
# network config
x
=
paddle
.
layer
.
data
(
name
=
'x'
,
type
=
paddle
.
data_type
.
dense_vector
(
13
))
...
...
02.recognize_digits/train.py
浏览文件 @
9f5d2171
...
...
@@ -3,6 +3,7 @@ from PIL import Image
import
numpy
as
np
import
paddle.v2
as
paddle
with_gpu
=
os
.
getenv
(
'WITH_GPU'
,
'0'
)
!=
'0'
def
softmax_regression
(
img
):
predict
=
paddle
.
layer
.
fc
(
...
...
@@ -49,7 +50,7 @@ def convolutional_neural_network(img):
def
main
():
paddle
.
init
(
use_gpu
=
False
,
trainer_count
=
1
)
paddle
.
init
(
use_gpu
=
with_gpu
,
trainer_count
=
1
)
# define network topology
images
=
paddle
.
layer
.
data
(
...
...
03.image_classification/train.py
浏览文件 @
9f5d2171
...
...
@@ -12,20 +12,21 @@
# See the License for the specific language governing permissions and
# limitations under the License
import
sys
import
sys
,
os
import
paddle.v2
as
paddle
from
vgg
import
vgg_bn_drop
from
resnet
import
resnet_cifar10
with_gpu
=
os
.
getenv
(
'WITH_GPU'
,
'0'
)
!=
'0'
def
main
():
datadim
=
3
*
32
*
32
classdim
=
10
# PaddlePaddle init
paddle
.
init
(
use_gpu
=
False
,
trainer_count
=
1
)
paddle
.
init
(
use_gpu
=
with_gpu
,
trainer_count
=
1
)
image
=
paddle
.
layer
.
data
(
name
=
"image"
,
type
=
paddle
.
data_type
.
dense_vector
(
datadim
))
...
...
04.word2vec/train.py
浏览文件 @
9f5d2171
import
math
import
math
,
os
import
paddle.v2
as
paddle
with_gpu
=
os
.
getenv
(
'WITH_GPU'
,
'0'
)
!=
'0'
embsize
=
32
hiddensize
=
256
N
=
5
...
...
@@ -17,7 +19,7 @@ def wordemb(inlayer):
def
main
():
paddle
.
init
(
use_gpu
=
False
,
trainer_count
=
3
)
paddle
.
init
(
use_gpu
=
with_gpu
,
trainer_count
=
3
)
word_dict
=
paddle
.
dataset
.
imikolov
.
build_dict
()
dict_size
=
len
(
word_dict
)
# Every layer takes integer value of range [0, dict_size)
...
...
05.recommender_system/train.py
浏览文件 @
9f5d2171
import
paddle.v2
as
paddle
import
cPickle
import
copy
import
os
with_gpu
=
os
.
getenv
(
'WITH_GPU'
,
'0'
)
!=
'0'
def
get_usr_combined_features
():
uid
=
paddle
.
layer
.
data
(
...
...
@@ -67,7 +69,7 @@ def get_mov_combined_features():
def
main
():
paddle
.
init
(
use_gpu
=
False
)
paddle
.
init
(
use_gpu
=
with_gpu
)
usr_combined_features
=
get_usr_combined_features
()
mov_combined_features
=
get_mov_combined_features
()
inference
=
paddle
.
layer
.
cos_sim
(
...
...
06.understand_sentiment/train.py
浏览文件 @
9f5d2171
...
...
@@ -12,9 +12,10 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import
sys
import
sys
,
os
import
paddle.v2
as
paddle
with_gpu
=
os
.
getenv
(
'WITH_GPU'
,
'0'
)
!=
'0'
def
convolution_net
(
input_dim
,
class_dim
=
2
,
emb_dim
=
128
,
hid_dim
=
128
):
data
=
paddle
.
layer
.
data
(
"word"
,
...
...
@@ -102,7 +103,7 @@ def stacked_lstm_net(input_dim,
if
__name__
==
'__main__'
:
# init
paddle
.
init
(
use_gpu
=
False
)
paddle
.
init
(
use_gpu
=
with_gpu
)
#data
print
'load dictionary...'
...
...
07.label_semantic_roles/train.py
浏览文件 @
9f5d2171
import
math
import
math
,
os
import
numpy
as
np
import
paddle.v2
as
paddle
import
paddle.v2.dataset.conll05
as
conll05
import
paddle.v2.evaluator
as
evaluator
with_gpu
=
os
.
getenv
(
'WITH_GPU'
,
'0'
)
!=
'0'
word_dict
,
verb_dict
,
label_dict
=
conll05
.
get_dict
()
word_dict_len
=
len
(
word_dict
)
label_dict_len
=
len
(
label_dict
)
...
...
@@ -118,7 +120,7 @@ def load_parameter(file_name, h, w):
def
main
():
paddle
.
init
(
use_gpu
=
False
,
trainer_count
=
1
)
paddle
.
init
(
use_gpu
=
with_gpu
,
trainer_count
=
1
)
# define network topology
feature_out
=
db_lstm
()
...
...
08.machine_translation/train.py
浏览文件 @
9f5d2171
import
sys
import
sys
,
os
import
numpy
as
np
import
paddle.v2
as
paddle
with_gpu
=
os
.
getenv
(
'WITH_GPU'
,
'0'
)
!=
'0'
def
save_model
(
parameters
,
save_path
):
with
open
(
save_path
,
'w'
)
as
f
:
...
...
@@ -135,7 +135,7 @@ def seq_to_seq_net(source_dict_dim,
def
main
():
paddle
.
init
(
use_gpu
=
False
,
trainer_count
=
1
)
paddle
.
init
(
use_gpu
=
with_gpu
,
trainer_count
=
1
)
is_generating
=
False
# source and target dict dim.
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录