集群多节点预测数据重复
paddle cluster_train
--config=$cfg
--log_period=100
--dot_period=10
--num_passes=100
--use_gpu=cpu
--test_period=0
--show_parameter_stats_period=100
--time_limit=700:00:00
--where=nmg01-hpc-off-dmop-slow-cpu-10G_cluster
--submitter=caoqixiu
--num_nodes=5
--job=test
--job_priority=normal
--job_name=caoqixiu_ecom_price_evaluate
--thirdparty=./thirdparty
2>&1 | tee 'predict.log'
如上, 使用5个节点预测(num_nodes=5), 但 output 目录中, rank-00000 到 rank-00004 目录下数据都是相同的.
麻烦提供一下链接, 提供更多的信息,包括学习过程日志,以及模型配置文件
http://nmg01-hpc-off-mon.dmop.baidu.com:8090/job/i-640646/
job_conf.py :
import os
import sys
import math
from paddle.trainer_config_helpers import *
################################ Parameters #################################
dict_file = "./feature_count.dat"
feature_show_thr = 10
is_local = False
is_predict = True
model_type('nn')
######
if not is_local:
cluster_config(
fs_name='xxx',
fs_ugi='xxx',
init_model_path='xxx',
train_data_path='xxx',
test_data_path='xxx',
output_path='xxx'
)
module_name = 'data_provider'
trn = './train.list'
tst = './test.list'
define_py_data_sources2(
train_list=trn,
test_list=tst,
module=module_name,
obj='process')
else:
module_name = 'data_provider'# if not is_predict else 'data_provider_predict'
trn = './data/train.list' if not is_predict else None
tst = './test.list'
define_py_data_sources2(
train_list=trn,
test_list=tst,
module=module_name,
obj='process')
word_dict = dict()
with open(dict_file, 'r') as f:
for line in f:
flds = line.strip().split('\t')
count = int( flds[1] )
if count > feature_show_thr:
try:
[sid, v] = flds[0].split(":")
except:
continue
if sid not in word_dict:
word_dict[sid] = {}
if v not in word_dict[sid]:
word_dict[sid][v] = len(word_dict[sid])+1
if is_predict:
outputs([data_layer(name="label", size=1), output])
else:
label = data_layer(name="label", size=1)
cls = regression_cost(input=output, label=label)
outputs(cls)
观察了一下你的训练日志,第一个AvgCost就是0,请检查一下你的输入数据还有标签,check一下dataprovider程序是否可以提供预期的数据。
0 是自己设置的, 主要是为了复现这个问题, data_provider.py:
import os
import sys
import random
random.seed( 10 )
import numpy as np
from paddle.trainer.PyDataProvider2 import *
UNK_IDX = 0
def initializer(settings, *file_list,**kwargs):
dict_file = "./thirdparty/feature_count.dat"#"./feature_space.dat"
dictionary = dict(); feature_show_thr = 10
drop_feature_dictionary = dict()
with open(dict_file, 'r') as f:
for line in f:
flds = line.strip().split('\t')
count = int( flds[1] )
try:
[sid, v] = flds[0].split(":")
except:
continue
if count > feature_show_thr:
if sid not in dictionary:
dictionary[sid] = {}
if v not in dictionary[sid]:
dictionary[sid][v] = len(dictionary[sid])+1
if count < 1500:
if flds[0] not in drop_feature_dictionary:
drop_feature_dictionary[flds[0]] = 1
print 'dictionary size:', len(dictionary)
for i in range(1,8):
print 'slot',str(i),'size:',len(dictionary[str(i)])
settings.drop_feature_dict = drop_feature_dictionary
settings.word_dict = dictionary
settings.input_types = {
'1': integer_value_sequence(len(dictionary['1'])),# query
'2': integer_value_sequence(len(dictionary['2'])),# word
'3': integer_value_sequence(len(dictionary['3'])),# wmatch
'4': integer_value_sequence(len(dictionary['4'])),# entity_id
'5': integer_value_sequence(len(dictionary['5'])),# tradeid
'6':integer_value_sequence(len(dictionary['6'])), # show_time
'7':integer_value_sequence(len(dictionary['7'])), # pid
'label': dense_vector(1)
}
@provider(use_seq=True,init_hook=initializer,pool_size=200)#cache=CacheType.CACHE_PASS_IN_MEM)
def process(settings, file_name):
with open(file_name, 'r') as f:
for line in f:
items = line.strip().split(',')
input_dict = { k:[] for k in settings.word_dict.keys()+['label'] }
label = 0.0
try:
input_dict['label'] = [label]
for ori_w in items[0].split('\t'):
w = ori_w.split(":")
feature_value = settings.word_dict[w[0]].get(w[1], UNK_IDX)
if random.randint(1,10) == 1 and ori_w in settings.drop_feature_dict:
feature_value = UNK_IDX
input_dict[w[0]].append( feature_value )
except:
continue
yield input_dict
跑离线预测,job=test的时候应该是使用train_data_path指定的路径作为输入数据才可以平均分布在多个节点,使用test_data_path的话,每个节点都是全部数据了。 @Yancey1989 麻烦晚点看下额。
用capi开发预测程序,再把你的依赖的jumbo包上传到hdfs上,然后在map里面写调预测程序。
@typhoonzero test_data_path不需要填写? paddle 会对 train_data_path 里面的数据进行预测吗