我正在尝试创建一个simple audio recognition来发现关键词。由于我的数据集很小,我正在进行转学习。这是如何graph looks。在这个link之后,我创建了一个模块。这是代码
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
)通常很有用。