Skip to content
This repository was archived by the owner on Jul 1, 2024. It is now read-only.

Commit 01d59d3

Browse files
Prepare for Keras-MXNet v2.2.2 release
Prepare for Keras-MXNet v2.2.2 release
2 parents c0f4ef6 + 840d757 commit 01d59d3

File tree

91 files changed

+1607
-1626
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

91 files changed

+1607
-1626
lines changed

.coveragerc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
[report]
22
# Regexes for lines to exclude from consideration
33
exclude_lines =
4+
pragma: no cover
45
os.remove
56
except ImportError
67
# Don't complain if tests don't hit defensive assertion code:

.travis.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,19 +54,19 @@ install:
5454
# install PIL for preprocessing tests
5555
- if [[ "$TRAVIS_PYTHON_VERSION" == "2.7" ]]; then
5656
conda install pil;
57-
elif [[ "$TRAVIS_PYTHON_VERSION" == "3.6" ]]; then
57+
else
5858
conda install Pillow;
5959
fi
6060

6161
- pip install -e .[tests]
6262

6363
# install TensorFlow (CPU version).
6464
- pip install tensorflow==1.7
65-
66-
# install Apache MXNet (CPU version).
65+
66+
# install Apache MXNet (CPU version).
6767
- pip install mxnet
6868
- pip install --upgrade numpy
69-
69+
7070
# install cntk
7171
- if [[ "$TRAVIS_PYTHON_VERSION" == "2.7" ]]; then
7272
pip install https://cntk.ai/PythonWheel/CPU-Only/cntk-2.5.1-cp27-cp27mu-linux_x86_64.whl;

ISSUE_TEMPLATE.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ Thank you!
55
- [ ] Check that you are up-to-date with the master branch of Keras. You can update with:
66
pip install git+git://github.com/awslabs/keras-apache-mxnet.git --upgrade --no-deps
77

8+
- [ ] If running on MXNet, check that you are up-to-date with the latest version. The installation
9+
instructions can be found [here](http://mxnet.incubator.apache.org/install/index.html?platform=Linux&language=Python&processor=CPU)
810
- [ ] If running on TensorFlow, check that you are up-to-date with the latest version. The installation instructions can be found [here](https://www.tensorflow.org/get_started/os_setup).
911

1012
- [ ] If running on Theano, check that you are up-to-date with the master branch of Theano. You can update with:

PULL_REQUEST_TEMPLATE.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
### Summary
2+
3+
### Related Issues
4+
5+
### PR Overview
6+
7+
- [ ] This PR requires new unit tests [y/n] (make sure tests are included)
8+
- [ ] This PR requires to update the documentation [y/n] (make sure the docs are up-to-date)
9+
- [ ] This PR is backwards compatible [y/n]
10+
- [ ] This PR changes the current API [y/n]

benchmark/README.md

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
2. [Library Versions](#library-versions)
77
3. [CNN Benchmarks](#cnn-benchmarks)
88
1. [CNN Benchmark Results](#cnn-benchmark-results)
9+
2. [CNN Inference Benchmark Results](#cnn-inference-benchmark-results)
910
4. [RNN Benchmarks (Experimental)](#rnn-benchmarks-experimental)
1011
5. [Setup](#setup)
1112
6. [How to Run CNN Benchmarks](#how-to-run-cnn-benchmarks)
@@ -89,7 +90,16 @@ NOTE:
8990
You can see more benchmark experiments with different instance types, batch_size and other parameters in [detailed CNN
9091
results document](benchmark_result/CNN_result.md).
9192

92-
93+
94+
### CNN Inference Benchmark Results
95+
96+
#### ResNet50-Synthetic Data
97+
98+
| Instance Type | GPUs | Batch Size | Keras-MXNet (img/sec) | Keras-TensorFlow (img/sec) |
99+
|---|---|---|---|---|
100+
| C5.X Large | 0 | 32 | 5.79 | 3.27 |
101+
| C5.8X Large | 0 | 32 | 27.9 | 18.2 |
102+
93103
```
94104
NOTE:
95105
1. Image_data_format for MXNet backend - 'channels_first'
@@ -192,6 +202,18 @@ For TensorFlow backend benchmarks:
192202
$ sh run_tf_backend.sh 8_gpu_config resnet50 False 20 # For 8 GPU Benchmarks
193203
```
194204

205+
### ResNet50-Synthetic Inference Benchmarks
206+
207+
For MXNet backend inference benchmarks:
208+
```
209+
$ sh run_mxnet_backend.sh cpu_config resnet50 True 20
210+
```
211+
212+
For TensorFlow backend inference benchmarks:
213+
```
214+
$ sh run_tf_backend.sh cpu_config resnet50 True 20
215+
```
216+
195217
The last parameter, 20, in the command is the number of epoch.
196218

197219
## How to Run RNN Benchmarks
@@ -260,4 +282,4 @@ For TensorFlow backend benchmarks:
260282
## References
261283

262284
* [TensorFlow Keras Benchmarks](https://github.com/tensorflow/benchmarks/tree/keras-benchmarks/scripts/keras_benchmarks)
263-
* [lstm_text_generation.py](https://github.com/keras-team/keras/blob/master/examples/lstm_text_generation.py)
285+
* [lstm_text_generation.py](https://github.com/keras-team/keras/blob/master/examples/lstm_text_generation.py)
7.7 KB
Loading

benchmark/scripts/run_benchmark.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,11 @@ def get_backend_version():
6666

6767
use_dataset_tensors = False
6868
if args.epochs:
69-
model.run_benchmark(gpus=config['gpus'], inference=inference, use_dataset_tensors=use_dataset_tensors, epochs=int(args.epochs))
69+
model.run_benchmark(gpus=config['gpus'], inference=inference,
70+
use_dataset_tensors=use_dataset_tensors,
71+
epochs=int(args.epochs))
7072
else:
71-
model.run_benchmark(gpus=config['gpus'], inference=inference, use_dataset_tensors=use_dataset_tensors)
73+
model.run_benchmark(gpus=config['gpus'], inference=inference,
74+
use_dataset_tensors=use_dataset_tensors)
7275
if args.dry_run:
7376
print("Model :total_time", model.test_name, model.total_time)

docs/autogen.py

Lines changed: 45 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@
9999
'deserialize',
100100
'get',
101101
'set_image_dim_ordering',
102+
'normalize_data_format',
102103
'image_dim_ordering',
103104
'get_variable_shape',
104105
}
@@ -114,7 +115,7 @@
114115
PAGES = [
115116
{
116117
'page': 'models/sequential.md',
117-
'functions': [
118+
'methods': [
118119
models.Sequential.compile,
119120
models.Sequential.fit,
120121
models.Sequential.evaluate,
@@ -130,7 +131,7 @@
130131
},
131132
{
132133
'page': 'models/model.md',
133-
'functions': [
134+
'methods': [
134135
models.Model.compile,
135136
models.Model.fit,
136137
models.Model.evaluate,
@@ -341,32 +342,6 @@
341342
ROOT = 'http://keras.io/'
342343

343344

344-
def get_earliest_class_that_defined_member(member, cls):
345-
ancestors = get_classes_ancestors([cls])
346-
result = None
347-
for ancestor in ancestors:
348-
if member in dir(ancestor):
349-
result = ancestor
350-
if not result:
351-
return cls
352-
return result
353-
354-
355-
def get_classes_ancestors(classes):
356-
ancestors = []
357-
for cls in classes:
358-
ancestors += cls.__bases__
359-
filtered_ancestors = []
360-
for ancestor in ancestors:
361-
if ancestor.__name__ in ['object']:
362-
continue
363-
filtered_ancestors.append(ancestor)
364-
if filtered_ancestors:
365-
return filtered_ancestors + get_classes_ancestors(filtered_ancestors)
366-
else:
367-
return filtered_ancestors
368-
369-
370345
def get_function_signature(function, method=True):
371346
wrapped = getattr(function, '_original_function', None)
372347
if wrapped is None:
@@ -395,10 +370,6 @@ def get_function_signature(function, method=True):
395370
signature = st[:-2] + ')'
396371
else:
397372
signature = st + ')'
398-
399-
if not method:
400-
# Prepend the module name.
401-
signature = clean_module_name(function.__module__) + '.' + signature
402373
return post_process_signature(signature)
403374

404375

@@ -409,12 +380,15 @@ def get_class_signature(cls):
409380
except (TypeError, AttributeError):
410381
# in case the class inherits from object and does not
411382
# define __init__
412-
class_signature = clean_module_name(cls.__module__) + '.' + cls.__name__ + '()'
383+
class_signature = "{clean_module_name}.{cls_name}()".format(
384+
clean_module_name=clean_module_name(cls.__module__),
385+
cls_name=cls.__name__
386+
)
413387
return post_process_signature(class_signature)
414388

415389

416390
def post_process_signature(signature):
417-
parts = re.split('\.(?!\d)', signature)
391+
parts = re.split(r'\.(?!\d)', signature)
418392
if len(parts) >= 4:
419393
if parts[1] == 'layers':
420394
signature = 'keras.layers.' + '.'.join(parts[3:])
@@ -459,7 +433,7 @@ def code_snippet(snippet):
459433

460434

461435
def count_leading_spaces(s):
462-
ws = re.search('\S', s)
436+
ws = re.search(r'\S', s)
463437
if ws:
464438
return ws.start()
465439
else:
@@ -468,7 +442,8 @@ def count_leading_spaces(s):
468442

469443
def process_list_block(docstring, starting_point, leading_spaces, marker):
470444
ending_point = docstring.find('\n\n', starting_point)
471-
block = docstring[starting_point:None if ending_point == -1 else ending_point - 1]
445+
block = docstring[starting_point:(None if ending_point == -1 else
446+
ending_point - 1)]
472447
# Place marker for later reinjection.
473448
docstring = docstring.replace(block, marker)
474449
lines = block.split('\n')
@@ -596,7 +571,6 @@ def process_docstring(docstring):
596571
shutil.copy(fpath, new_fpath)
597572

598573

599-
# Take care of index page.
600574
def read_file(path):
601575
with open(path) as f:
602576
return f.read()
@@ -616,16 +590,37 @@ def collect_class_methods(cls, methods):
616590
def render_function(function, method=True):
617591
subblocks = []
618592
signature = get_function_signature(function, method=method)
619-
signature = signature.replace(function.__module__ + '.', '')
620-
level = 3
621-
subblocks.append('#' * level + ' ' + function.__name__ + '\n')
593+
if method:
594+
signature = signature.replace(
595+
clean_module_name(function.__module__) + '.', '')
596+
subblocks.append('### ' + function.__name__ + '\n')
622597
subblocks.append(code_snippet(signature))
623598
docstring = function.__doc__
624599
if docstring:
625600
subblocks.append(process_docstring(docstring))
626601
return '\n\n'.join(subblocks)
627602

628603

604+
def read_page_data(page_data, type):
605+
assert type in ['classes', 'functions', 'methods']
606+
data = page_data.get(type, [])
607+
for module in page_data.get('all_module_{}'.format(type), []):
608+
module_data = []
609+
for name in dir(module):
610+
if name[0] == '_' or name in EXCLUDE:
611+
continue
612+
module_member = getattr(module, name)
613+
if (inspect.isclass(module_member) and type == 'classes' or
614+
inspect.isfunction(module_member) and type == 'functions'):
615+
instance = module_member
616+
if module.__name__ in instance.__module__:
617+
if instance not in module_data:
618+
module_data.append(instance)
619+
module_data.sort(key=lambda x: id(x))
620+
data += module_data
621+
return data
622+
623+
629624
if __name__ == '__main__':
630625
readme = read_file('../README.md')
631626
index = read_file('templates/index.md')
@@ -635,22 +630,9 @@ def render_function(function, method=True):
635630

636631
print('Generating docs for Keras %s.' % keras.__version__)
637632
for page_data in PAGES:
638-
blocks = []
639-
classes = page_data.get('classes', [])
640-
for module in page_data.get('all_module_classes', []):
641-
module_classes = []
642-
for name in dir(module):
643-
if name[0] == '_' or name in EXCLUDE:
644-
continue
645-
module_member = getattr(module, name)
646-
if inspect.isclass(module_member):
647-
cls = module_member
648-
if cls.__module__ == module.__name__:
649-
if cls not in module_classes:
650-
module_classes.append(cls)
651-
module_classes.sort(key=lambda x: id(x))
652-
classes += module_classes
633+
classes = read_page_data(page_data, 'classes')
653634

635+
blocks = []
654636
for element in classes:
655637
if not isinstance(element, (list, tuple)):
656638
element = (element, [])
@@ -675,20 +657,12 @@ def render_function(function, method=True):
675657
[render_function(method, method=True) for method in methods]))
676658
blocks.append('\n'.join(subblocks))
677659

678-
functions = page_data.get('functions', [])
679-
for module in page_data.get('all_module_functions', []):
680-
module_functions = []
681-
for name in dir(module):
682-
if name[0] == '_' or name in EXCLUDE:
683-
continue
684-
module_member = getattr(module, name)
685-
if inspect.isfunction(module_member):
686-
function = module_member
687-
if module.__name__ in function.__module__:
688-
if function not in module_functions:
689-
module_functions.append(function)
690-
module_functions.sort(key=lambda x: id(x))
691-
functions += module_functions
660+
methods = read_page_data(page_data, 'methods')
661+
662+
for method in methods:
663+
blocks.append(render_function(method, method=True))
664+
665+
functions = read_page_data(page_data, 'functions')
692666

693667
for function in functions:
694668
blocks.append(render_function(function, method=False))
@@ -706,7 +680,8 @@ def render_function(function, method=True):
706680
if os.path.exists(path):
707681
template = read_file(path)
708682
assert '{{autogenerated}}' in template, ('Template found for ' + path +
709-
' but missing {{autogenerated}} tag.')
683+
' but missing {{autogenerated}}'
684+
' tag.')
710685
mkdown = template.replace('{{autogenerated}}', mkdown)
711686
print('...inserting autogenerated content into template:', path)
712687
else:

docs/templates/applications.md

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -533,15 +533,6 @@ MobileNet model, with weights pre-trained on ImageNet.
533533

534534
Note that this model only supports the data format `'channels_last'` (height, width, channels).
535535

536-
To load a MobileNet model via `load_model`, import the custom object `relu6` and pass it to the `custom_objects` parameter.
537-
538-
E.g.
539-
540-
```python
541-
model = load_model('mobilenet.h5', custom_objects={
542-
'relu6': mobilenet.relu6})
543-
```
544-
545536
The default input size for this model is 224x224.
546537

547538
### Arguments
@@ -732,15 +723,6 @@ MobileNetV2 model, with weights pre-trained on ImageNet.
732723

733724
Note that this model only supports the data format `'channels_last'` (height, width, channels).
734725

735-
To load a MobileNetV2 model via `load_model`, import the custom object `relu6` and pass it to the `custom_objects` parameter.
736-
737-
E.g.
738-
739-
```python
740-
model = load_model('mobilenet_v2.h5', custom_objects={
741-
'relu6': mobilenetv2.relu6})
742-
```
743-
744726
The default input size for this model is 224x224.
745727

746728
### Arguments

0 commit comments

Comments
 (0)