提交 9f5d2171 编写于 作者: D dzhwinter

config with gpu

上级 e75fd183
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))
......
......@@ -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(
......
......@@ -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))
......
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)
......
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(
......
......@@ -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...'
......
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()
......
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.
先完成此消息的编辑!
想要评论请 注册