我正在尝试创建一个简单的音频识别来发现关键词。由于我的数据集很小,我正在执行迁移学习。这就是图表的外观。按照这个链接我创建了一个模块。这是代码
import tensorflow_hub as hub
import tensorflow as tf
# pylint: disable=unused-import
from tensorflow.contrib.framework.python.ops import audio_ops as contrib_audio
# pylint: enable=unused-import
def module_fn():
input_name = "Reshape:0"
output_name = "Reshape_2:0"
graph_def = tf.GraphDef()
with open('my_frozen_graph.pb', "rb") as f:
graph_def.ParseFromString(f.read())
input_ten=tf.placeholder(tf.float32, shape = (1, 98, 40))
output_ten,=tf.import_graph_def(graph_def, input_map = {input_name: input_ten}, return_elements = [output_name])
hub.add_signature(inputs = input_ten, outputs = output_ten)
spec = hub.create_module_spec(module_fn)
module = hub.Module(spec)
with tf.Session() as session:
module.export('test_module',session)
尽管它确实执行并创建了一个“test_module”文件夹。
test_module
|--> assets
|--> variables
|--> saved_model.pb
|--> tfhub_module.pb
我怎么有几个问题
变量文件夹为空。不确定这是否应该是这样的?
input_ten=tf.placeholder(tf.float32, shape = (1, 98, 40))
这个对吗 ?98X48 是图像大小,第一个元组通常代表批量大小。它应该保持为 '1' 还是未知的批量大小 'None' ?将模块加载到脚本后
高度,宽度 = hub.get_expected_image_size('test_module')
给我一个错误。