可能的情况:
来源:chenxuhou.com
def save(url):
print url
for url in urls:
p.apply_async(save, args=(url,))#需要在参数后面添加逗号
如:
# 这是程序的主函数,在函数内部进行了子进程和子函数的调用,但是实际上由于子函数运行时并不会经过主函数,因此不会import,因此CNNClass无从调用。
def crossValidate(data_set_parent):
from CNN import CNNClass
parts = glob.glob(os.path.join(data_set_parent, 'part_*'))
pool = Pool(processes=4)
for i in parts:
iname = os.path.basename(i)
path_training = parts.copy()
path_testing = i
path_training.remove(i)
pool.apply_async(generateModel, (path_training, path_testing, 27, ...))
pool.close()
pool.join()
def generateModel(...):
CNNClass(...)
应将from CNN import CNNClass
放在文件头部。