嘿我已经在tensorflow中编写了一些用于预测声音(声音分类)的代码,但是当我构建时,我将此作为没有标签和分数的响应 *标签被假定为数字1-10
{
{
string_val: "0"
string_val: "1"
string_val: "2"
string_val: "3"
string_val: "4"
string_val: "5"
string_val: "6"
string_val: "7"
string_val: "8"
string_val: "9"
}
}
outputs {
key: "scores"
value {
dtype: DT_FLOAT
tensor_shape {
dim {
size: 1
}
dim {
size: 10
}
}
float_val: nan
float_val: nan
float_val: nan
float_val: nan
float_val: nan
float_val: nan
float_val: nan
float_val: nan
float_val: nan
float_val: nan
}
}
这是预测和分类代码
classification_signature = signature_def_utils.build_signature_def(
inputs={signature_constants.CLASSIFY_INPUTS: classification_inputs},
outputs={
signature_constants.CLASSIFY_OUTPUT_CLASSES:
classification_outputs_classes,
signature_constants.CLASSIFY_OUTPUT_SCORES:
classification_outputs_scores
},
method_name=signature_constants.CLASSIFY_METHOD_NAME)
tensor_info_x = utils.build_tensor_info(x)
tensor_info_y = utils.build_tensor_info(output)
prediction_signature = signature_def_utils.build_signature_def(
inputs={'sounds': tensor_info_x},
outputs={
'classes' : classification_outputs_classes,
'scores': classification_outputs_scores,
},
method_name=signature_constants.PREDICT_METHOD_NAME)
print('Exporting...')
legacy_init_op = tf.group(tf.initialize_all_tables(), name='legacy_init_op')
builder.add_meta_graph_and_variables(
sess, [tag_constants.SERVING],
signature_def_map={
'predict_sound':
prediction_signature,
signature_constants.DEFAULT_SERVING_SIGNATURE_DEF_KEY:
classification_signature,
},
legacy_init_op=legacy_init_op)
builder.save()