python - theano.function 如何成为 python 中另一个函数的输入?
问题描述
我有两个 .py 文件。在其中一个中,我有这个功能:
def score_semeval2015_term(pred_fn, nnet_outdir, data_dir):
def predict(dataset):
x_test = numpy.load(os.path.join(data_dir, 'semeval_{}_x.npy').format(dataset))
x_test_term = numpy.load(os.path.join(data_dir, 'semeval_{}_x_term.npy').format(dataset))
print dataset, x_test.shape
predictions = pred_fn(x_test, x_test_term)
y2label = {0: 'negative', 1: 'neutral', 2: 'positive'}
labels = [y2label[y] for y in predictions]
return labels
而 pred_fn 是在另一个 .py 文件中定义的 theano.function,如下所示:
pred_fn = theano.function(inputs=inputs_pred,
outputs=predictions,
givens=givens_pred)
我的问题是,一个函数怎么可能作为另一个函数的输入?调用 score_semeval2015_term(pred_fn, nnet_outdir, data_dir) 函数时应该如何获取它的输入?谢谢你。
解决方案
推荐阅读
- html - WordPress 安装后会改变我的整个网页设计吗?
- azure - 如何提前访问 Azure 应用服务中的配置?
- reactjs - 为什么 console.log("hello) 在 React hooks 中打印了六次
- xml - 使用 XSLT 格式化时间
- php - infusionsoft api - 如何通过使用联系人 ID 作为过滤器来获取联系人详细信息
- python - 如何使用python从单独的文件中删除一行
- javascript - Merge JS Together - 数据文本交换并复制到剪贴板
- c++ - 如何在批处理文件中传递文件位置
- python - Tensorflow 不工作:无法加载动态库“nvcuda.dll”;dlerror:未找到 nvcuda.dll
- flutter - 在监听 ObservableList 的 mobx 反应上获得相同的值