预测出现Matrix.cpp:527 Not supported
Created by: wangmengzhi
我照着demo写了一个小网络,将26个数直接传到全连接层训练得到0或1,训练没问题,用CPU预测也没问题,但用GPU预测的时候执行到network.forwardTest时出现
wmz@ubuntu:~/文档/GitHub/medical$ python prediction.py
I1217 10:56:02.716523 24392 Util.cpp:155] commandline: --use_gpu=1
I1217 10:56:03.042131 24392 Util.cpp:130] Calling runInitFunctions
I1217 10:56:03.042256 24392 Util.cpp:143] Call runInitFunctions done.
[INFO 2016-12-17 10:56:03,051 networks.py:1466] The input order is [data]
[INFO 2016-12-17 10:56:03,051 networks.py:1472] The output order is [__fc_layer_0__]
I1217 10:56:03.051918 24392 GradientMachine.cpp:123] Loading parameters from output_sex/pass-00029
F1217 10:56:03.052052 24392 Matrix.cpp:527] Not supported
*** Check failure stack trace: ***
@ 0x7f7b35b39daa (unknown)
@ 0x7f7b35b39ce4 (unknown)
@ 0x7f7b35b396e6 (unknown)
@ 0x7f7b35b3c687 (unknown)
@ 0x7f7b36d5c157 paddle::GpuMatrix::mul()
@ 0x7f7b36c72600 paddle::FullyConnectedLayer::forward()
@ 0x7f7b36cd946e paddle::NeuralNetwork::forward()
@ 0x7f7b36bb9fe5 _wrap_GradientMachine_forward
@ 0x49c4d9 (unknown)
@ 0x4a090c (unknown)
@ 0x49ab45 (unknown)
@ 0x4a090c (unknown)
@ 0x49ab45 (unknown)
@ 0x499ef2 (unknown)
@ 0x4a1634 (unknown)
@ 0x44e4a5 (unknown)
@ 0x44ec9f (unknown)
@ 0x44f904 (unknown)
@ 0x7f7b389dff45 (unknown)
@ 0x578c4e (unknown)
@ (nil) (unknown)
Aborted (core dumped)
网络配置文件trainer_config_sex.py是
# -*- coding: UTF-8 -*-
from paddle.trainer_config_helpers import *
is_predict = get_config_arg('is_predict', bool, False)
if not is_predict:
define_py_data_sources2(
train_list='train.list',
test_list='test.list',
module="dataprovider",
obj='process_sex')
settings(
batch_size=128,
learning_rate=2e-3,
learning_method=AdamOptimizer(),
regularization=L2Regularization(8e-4))
data = data_layer(name="data", size=26)
output = fc_layer(input=data, size=2, act=SoftmaxActivation())
if is_predict:
outputs(output)
else:
label = data_layer(name="label", size=2)
outputs(classification_cost(input=output, label=label))
预测文件prediction.py是
# -*- coding: UTF-8 -*-
from py_paddle import swig_paddle, DataProviderConverter
from paddle.trainer.PyDataProvider2 import dense_vector
from paddle.trainer.config_parser import parse_config
import numpy as np
TEST_DATA = [[[1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6]]]
def main():
swig_paddle.initPaddle("--use_gpu=1")
conf = parse_config("trainer_config_sex.py", "is_predict=1")
print conf.data_config.load_data_args
network = swig_paddle.GradientMachine.createFromConfigProto(conf.model_config)
network.loadParameters("output_sex/pass-00029")
converter = DataProviderConverter([dense_vector(26)])
inArg = converter(TEST_DATA)
network.forwardTest(inArg)
output = network.getLayerOutputs("__fc_layer_0__")
prob = output["__fc_layer_0__"].mean(0)
lab = np.argsort(-prob)
print lab[0]
if __name__ == '__main__':
main()
请问错在哪?