From 993642856e3d6c6300cc12e3f1848f7b6015cf29 Mon Sep 17 00:00:00 2001 From: Yuduo Date: Fri, 1 Nov 2019 12:47:51 -0700 Subject: [PATCH] sync and update version number --- contributing.md | 1 - coremltools/__init__.py | 2 +- coremltools/models/model.py | 1 - coremltools/test/neural_network/test_keras2.py | 13 ++++++------- docs/APIExamples.md | 15 ++++++++------- 5 files changed, 15 insertions(+), 17 deletions(-) diff --git a/contributing.md b/contributing.md index 5128cfa61..8f11550a8 100644 --- a/contributing.md +++ b/contributing.md @@ -73,4 +73,3 @@ Additional information regarding APIs, installation and dependencies and more ca * [coremltools](https://github.com/apple/coremltools) * [onnx-coreml](https://github.com/onnx/onnx-coreml) * [tf-coreml](https://github.com/tf-coreml/tf-coreml) - diff --git a/coremltools/__init__.py b/coremltools/__init__.py index 65f77cc08..3c85cb647 100644 --- a/coremltools/__init__.py +++ b/coremltools/__init__.py @@ -22,7 +22,7 @@ For more information: http://developer.apple.com/documentation/coreml """ -__version__ = '3.0' +__version__ = '3.1' # This is the basic Core ML specification format understood by iOS 11.0 SPECIFICATION_VERSION = 1 diff --git a/coremltools/models/model.py b/coremltools/models/model.py index d135bd13f..56e3073b5 100644 --- a/coremltools/models/model.py +++ b/coremltools/models/model.py @@ -372,7 +372,6 @@ def visualize_spec(self, port=None, input_shape_dict=None, title='CoreML Graph V Returns ------- - None Examples diff --git a/coremltools/test/neural_network/test_keras2.py b/coremltools/test/neural_network/test_keras2.py index ce2284e3d..903152307 100644 --- a/coremltools/test/neural_network/test_keras2.py +++ b/coremltools/test/neural_network/test_keras2.py @@ -329,7 +329,7 @@ def test_pooling(self): # Create a simple Keras model model = Sequential() model.add(Conv2D(input_shape=(64, 64, 3), - filters=32, kernel_size=(5,5), strides=(1,1), activation=None, + filters=32, kernel_size=(5,5), strides=(1,1), activation=None, padding='valid', use_bias=True)) model.add(MaxPooling2D(pool_size=(2,2))) @@ -611,7 +611,7 @@ def test_sentiment_analysis(self): self.assertTrue(spec.HasField('neuralNetwork')) # Test the inputs and outputs - # We're giving state input and output so expect description to differ. + # We're giving state input and output so expect description to differ. self.assertEquals(len(spec.description.input), len(input_names) + 2) self.assertEquals(len(spec.description.output), len(output_names) + 2) @@ -657,7 +657,7 @@ def test_batchnorm(self): # Create a simple Keras model model = Sequential() model.add(Conv2D(input_shape=(64, 64, 3), - filters=32, kernel_size=(5,5), strides=(1,1), activation=None, + filters=32, kernel_size=(5,5), strides=(1,1), activation=None, padding='valid', use_bias=True)) # epsilon in CoreML is currently fixed at 1e-5 model.add(BatchNormalization(epsilon=1e-5)) @@ -731,8 +731,8 @@ def test_image_processing(self): # Create a simple Keras model model = Sequential() model.add(Conv2D(input_shape=(64, 64, 3), - filters=32, kernel_size=(5,5), - activation=None, padding='valid', + filters=32, kernel_size=(5,5), + activation=None, padding='valid', strides=(1, 1), use_bias=True)) input_names = ['input'] output_names = ['output'] @@ -1270,7 +1270,7 @@ def test_updatable_model_flag_cce_string_sgd(self): self.assertEqual(sgdopt.miniBatchSize.defaultValue, 16) self.assertEqual(sgdopt.momentum.defaultValue, 0.0) - + def test_updatable_model_flag_cce_sgd_string(self): """ Tests the 'respect_trainable' flag when used along with string @@ -1344,4 +1344,3 @@ def test_updatable_model_flag_cce_adam_string(self): self.assertAlmostEqual(adopt.miniBatchSize.defaultValue, 16) self.assertAlmostEqual(adopt.beta1.defaultValue, 0.90, places=5) self.assertAlmostEqual(adopt.beta2.defaultValue, 0.999, places=5) - diff --git a/docs/APIExamples.md b/docs/APIExamples.md index 662e44104..8029d72ec 100644 --- a/docs/APIExamples.md +++ b/docs/APIExamples.md @@ -1,7 +1,8 @@ +docs/APIExamples.md # API Code snippets ## Converting between MLModel and Spec - + ```python import coremltools @@ -52,7 +53,7 @@ print_network_spec(spec) Another useful tool for visualizing CoreML models and models from other frameworks: [Netron](https://github.com/lutzroeder/netron) -## Printing the pre-processing parameters +## Printing the pre-processing parameters This is useful for image based neural network models @@ -77,7 +78,7 @@ print(nn.preprocessing) ## Changing MLMultiArray input/output datatypes [Here](https://github.com/apple/coremltools/blob/d07421460f9f0ad1a2e9cf8b5248670358a24a1a/mlmodel/format/FeatureTypes.proto#L106 ) is the list of supported datatypes. -For instance, change the datatype from 'double' to 'float32': +For instance, change the datatype from 'double' to 'float32': ```python import coremltools @@ -115,7 +116,7 @@ import PIL.Image model = coremltools.models.MLModel('path/to/the/saved/model.mlmodel') -Height = 20 # use the correct input image height +Height = 20 # use the correct input image height Width = 60 # use the correct input image width @@ -129,7 +130,7 @@ def load_image(path, resize_to=None): return img_np, img -# load the image and resize using PIL utilities +# load the image and resize using PIL utilities _, img = load_image('/path/to/image.jpg', resize_to=(Width, Height)) out_dict = model.predict({'image': img}) @@ -143,8 +144,8 @@ out_dict = model.predict({'image': pil_img}) ## Building an mlmodel from scratch using Neural Network Builder -We can use the neural network builder class to construct a CoreML model. Lets look at an example of -making a tiny 2 layer model with a convolution layer (with random weights) and an activation. +We can use the neural network builder class to construct a CoreML model. Lets look at an example of +making a tiny 2 layer model with a convolution layer (with random weights) and an activation. ```python import coremltools