def test_classifier_no_name(self):
np.random.seed(1988)
input_dim = 5
num_hidden = 12
num_classes = 6
input_length = 3
model = Sequential()
model.add(LSTM(num_hidden, input_dim=input_dim, input_length=input_length, return_sequences=False))
model.add(Dense(num_classes, activation='softmax'))
model.set_weights([np.random.rand(*w.shape) for w in model.get_weights()])
input_names = ['input']
output_names = ['zzzz']
class_labels = ['a', 'b', 'c', 'd', 'e', 'f']
predicted_feature_name = 'pf'
coremlmodel = keras_converter.convert(model, input_names, output_names, class_labels=class_labels, predicted_feature_name=predicted_feature_name)
inputs = np.random.rand(input_dim)
outputs = coremlmodel.predict({'input': inputs})
# this checks that the dictionary got the right name and type
self.assertEquals(type(outputs[output_names[0]]), type({'a': 0.5}))
评论列表
文章目录