python - Keras/Tensorflow prediction used in another program to calculate loss
问题描述
There is a pipeline I want to try that utilizes Keras/Tensorflow with another program. My 'very professional' diagram below shows what I am trying to accomplish
CNN with external program pipeline
The input to the CNN is a 2D-matrix and the output is a 2D matrix with the same dimensions as the input matrix. I want to feed the prediction into a separate program, which computes a new 2D matrix that should then be compared with the input matrix to calculate the loss.
I know that this would be slow to compute, but I still want to know if it is feasible. My first idea was to modify the loss function to interface with the external program - but a small amount of research seems to indicate that this is not possible. Is there some other way to interject a separate program to the loss function, or is there some other way to rework this pipeline?
Any suggestions are greatly appreciated!
解决方案
简短的回答是不,一般来说这是不可能的。这是因为 CNN 和任何神经网络都是通过使用反向传播和损失函数来训练的。如果要执行反向传播,您需要知道将输入 x 转换为输出 y 的过程。这样你就可以计算梯度。如果您使用黑盒程序作为等式的一部分,则无法进行反向传播。
一些可能的建议。
- 如果可行,您可以训练一个卷积网络来模拟黑盒程序,然后就可以将其用作训练的一部分。
- 你可以做一些其他形式的优化,在没有梯度的情况下工作/与黑盒损失函数一起工作。
推荐阅读
- php - 如何在 PHP 7 中为 Mongodb 连接启用 libmongoc ssl?
- vb.net - 使用 VB.net - 从 GitLab 拉文件
- unity3d - 使用脚本直接控制Unity中的.fbx MakeHuman Avatar
- cypress - 添加 Cypress 自动运行手表测试的延迟
- marklogic - Marklogic如何将xquery文件存储到模块数据库中
- php - 正则表达式匹配部分行,然后看后面并替换(并删除该行)
- ios - 如何使用 Swift SpriteKit 在 For 循环中一一创建 SKSprite 节点
- ruby - 作为 TTY 输出到 $stdout 并同时捕获输出
- python-2.7 - Tkinter 列表框中的行为差异,箭头键与鼠标单击
- angular - 服务中的 Angular2 变量未更新