首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Lasagne/Theano,加载酸洗模型时出现问题

Lasagne/Theano,加载酸洗模型时出现问题
EN

Stack Overflow用户
提问于 2016-10-20 00:40:01
回答 1查看 133关注 0票数 2

我想我在这一点上已经失去理智了。

我在用千层面做一个小的卷积神经网络。它训练得很好,我也可以计算训练集和验证集的误差,但我不能将训练好的模型保存在磁盘上。更好的是,我可以保存并加载它,但我不能使用它来预测新数据。

这就是我在训练后做的事情

代码语言:javascript
复制
model = {'network': network, 'params': get_all_params(network), 'params_values': get_all_param_values(network)}
pickle.dump(model, open('models/model_1.pkl', 'wb'), protocol=pickle.HIGHEST_PROTOCOL)

这是我用来加载模型的方法

代码语言:javascript
复制
with open('models/model.pkl', 'rb') as pickle_file:
    model = pickle.load(pickle_file)

network = model['network']
values = model['params_values']

set_all_param_values(network, values)

T_input = T.tensor4('input', dtype='float32')
T_target = T.ivector('target')

predictions = get_output(network, deterministic=True)

loss = (cross_entropy(predictions, T_target)).mean()

acc = T.mean(T.eq(T.argmax(predictions, axis=1), T_target), dtype=config.floatX)

test_fn = function([T_input, T_target], [loss, acc])

我甚至不能传递实际的numpy输入,因为我得到了这个错误

代码语言:javascript
复制
theano.compile.function_module.UnusedInputError: theano.function was asked to create a 
function computing outputs given certain inputs, but the provided input variable at index 0 
is not part of the computational graph needed to compute the outputs: input.
To make this error into a warning, you can pass the parameter   
on_unused_input='warn' to theano.function. To disable it completely, use 
on_unused_input='ignore'.

然后我尝试设置参数on_unused_input='warn‘,结果如下

代码语言:javascript
复制
theano.gof.fg.MissingInputError: An input of the graph, used to compute (..)   
was not provided and not given a value.Use the Theano flag 
exception_verbosity='high',for more information on this error.
EN

回答 1

Stack Overflow用户

发布于 2017-01-05 07:46:39

问题是您的T_input没有绑定到输入层,因此theano无法对其进行编译

代码语言:javascript
复制
T_input = lasagne.layers.get_all_layers(network)[0].input_var
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/40137113

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档