简体   繁体   English

keras中的中间层的输出通过DirectoryIterator作为输入

[英]Output of an intermediate layer in keras passing as input a DirectoryIterator

Is there a way to get the output of a intermediate layer in Keras passing a DirectoryIterator as input? 有没有办法通过DirectoryIterator作为输入来获取Keras中的中间层的输出?

I've already read the documentation of Keras related to this and this question but as far as I undertood, those approaches use single samples as input. 我已经阅读了与此问题 相关的Keras文档,但据我所知,这些方法使用单个样本作为输入。

I want to do this because it is more simple than read sample by sample and less computationally expensive than put everything on memory. 我要这样做是因为它比逐个样本读取更简单,并且比将所有内容都存储在内存中的计算成本更低。

I'm using TensorFlow as backend. 我正在使用TensorFlow作为后端。

desiredOutputs = model.get_layer('layer_name').outputs #or model.layers[n].outputs
partialModel = Model(model.inputs,desiredOutputs)

Then use partialModel to fit or predict with the directory iterator. 然后使用partialModel fitpredict目录迭代器。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM