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

Commit

Permalink
Prepare for Keras-MXNet v2.2.2 release
Browse files Browse the repository at this point in the history
Prepare for Keras-MXNet v2.2.2 release
  • Loading branch information
sandeep-krishnamurthy authored Aug 15, 2018
2 parents c0f4ef6 + 840d757 commit 01d59d3
Show file tree
Hide file tree
Showing 91 changed files with 1,607 additions and 1,626 deletions.
1 change: 1 addition & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
[report]
# Regexes for lines to exclude from consideration
exclude_lines =
pragma: no cover
os.remove
except ImportError
# Don't complain if tests don't hit defensive assertion code:
Expand Down
8 changes: 4 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,19 +54,19 @@ install:
# install PIL for preprocessing tests
- if [[ "$TRAVIS_PYTHON_VERSION" == "2.7" ]]; then
conda install pil;
elif [[ "$TRAVIS_PYTHON_VERSION" == "3.6" ]]; then
else
conda install Pillow;
fi

- pip install -e .[tests]

# install TensorFlow (CPU version).
- pip install tensorflow==1.7

# install Apache MXNet (CPU version).
# install Apache MXNet (CPU version).
- pip install mxnet
- pip install --upgrade numpy

# install cntk
- if [[ "$TRAVIS_PYTHON_VERSION" == "2.7" ]]; then
pip install https://cntk.ai/PythonWheel/CPU-Only/cntk-2.5.1-cp27-cp27mu-linux_x86_64.whl;
Expand Down
2 changes: 2 additions & 0 deletions ISSUE_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ Thank you!
- [ ] Check that you are up-to-date with the master branch of Keras. You can update with:
pip install git+git://github.com/awslabs/keras-apache-mxnet.git --upgrade --no-deps

- [ ] If running on MXNet, check that you are up-to-date with the latest version. The installation
instructions can be found [here](http://mxnet.incubator.apache.org/install/index.html?platform=Linux&language=Python&processor=CPU)
- [ ] 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).

- [ ] If running on Theano, check that you are up-to-date with the master branch of Theano. You can update with:
Expand Down
10 changes: 10 additions & 0 deletions PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
### Summary

### Related Issues

### PR Overview

- [ ] This PR requires new unit tests [y/n] (make sure tests are included)
- [ ] This PR requires to update the documentation [y/n] (make sure the docs are up-to-date)
- [ ] This PR is backwards compatible [y/n]
- [ ] This PR changes the current API [y/n]
26 changes: 24 additions & 2 deletions benchmark/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
2. [Library Versions](#library-versions)
3. [CNN Benchmarks](#cnn-benchmarks)
1. [CNN Benchmark Results](#cnn-benchmark-results)
2. [CNN Inference Benchmark Results](#cnn-inference-benchmark-results)
4. [RNN Benchmarks (Experimental)](#rnn-benchmarks-experimental)
5. [Setup](#setup)
6. [How to Run CNN Benchmarks](#how-to-run-cnn-benchmarks)
Expand Down Expand Up @@ -89,7 +90,16 @@ NOTE:
You can see more benchmark experiments with different instance types, batch_size and other parameters in [detailed CNN
results document](benchmark_result/CNN_result.md).



### CNN Inference Benchmark Results

#### ResNet50-Synthetic Data

| Instance Type | GPUs | Batch Size | Keras-MXNet (img/sec) | Keras-TensorFlow (img/sec) |
|---|---|---|---|---|
| C5.X Large | 0 | 32 | 5.79 | 3.27 |
| C5.8X Large | 0 | 32 | 27.9 | 18.2 |

```
NOTE:
1. Image_data_format for MXNet backend - 'channels_first'
Expand Down Expand Up @@ -192,6 +202,18 @@ For TensorFlow backend benchmarks:
$ sh run_tf_backend.sh 8_gpu_config resnet50 False 20 # For 8 GPU Benchmarks
```

### ResNet50-Synthetic Inference Benchmarks

For MXNet backend inference benchmarks:
```
$ sh run_mxnet_backend.sh cpu_config resnet50 True 20
```

For TensorFlow backend inference benchmarks:
```
$ sh run_tf_backend.sh cpu_config resnet50 True 20
```

The last parameter, 20, in the command is the number of epoch.

## How to Run RNN Benchmarks
Expand Down Expand Up @@ -260,4 +282,4 @@ For TensorFlow backend benchmarks:
## References

* [TensorFlow Keras Benchmarks](https://github.com/tensorflow/benchmarks/tree/keras-benchmarks/scripts/keras_benchmarks)
* [lstm_text_generation.py](https://github.com/keras-team/keras/blob/master/examples/lstm_text_generation.py)
* [lstm_text_generation.py](https://github.com/keras-team/keras/blob/master/examples/lstm_text_generation.py)
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 5 additions & 2 deletions benchmark/scripts/run_benchmark.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,11 @@ def get_backend_version():

use_dataset_tensors = False
if args.epochs:
model.run_benchmark(gpus=config['gpus'], inference=inference, use_dataset_tensors=use_dataset_tensors, epochs=int(args.epochs))
model.run_benchmark(gpus=config['gpus'], inference=inference,
use_dataset_tensors=use_dataset_tensors,
epochs=int(args.epochs))
else:
model.run_benchmark(gpus=config['gpus'], inference=inference, use_dataset_tensors=use_dataset_tensors)
model.run_benchmark(gpus=config['gpus'], inference=inference,
use_dataset_tensors=use_dataset_tensors)
if args.dry_run:
print("Model :total_time", model.test_name, model.total_time)
115 changes: 45 additions & 70 deletions docs/autogen.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@
'deserialize',
'get',
'set_image_dim_ordering',
'normalize_data_format',
'image_dim_ordering',
'get_variable_shape',
}
Expand All @@ -114,7 +115,7 @@
PAGES = [
{
'page': 'models/sequential.md',
'functions': [
'methods': [
models.Sequential.compile,
models.Sequential.fit,
models.Sequential.evaluate,
Expand All @@ -130,7 +131,7 @@
},
{
'page': 'models/model.md',
'functions': [
'methods': [
models.Model.compile,
models.Model.fit,
models.Model.evaluate,
Expand Down Expand Up @@ -341,32 +342,6 @@
ROOT = 'http://keras.io/'


def get_earliest_class_that_defined_member(member, cls):
ancestors = get_classes_ancestors([cls])
result = None
for ancestor in ancestors:
if member in dir(ancestor):
result = ancestor
if not result:
return cls
return result


def get_classes_ancestors(classes):
ancestors = []
for cls in classes:
ancestors += cls.__bases__
filtered_ancestors = []
for ancestor in ancestors:
if ancestor.__name__ in ['object']:
continue
filtered_ancestors.append(ancestor)
if filtered_ancestors:
return filtered_ancestors + get_classes_ancestors(filtered_ancestors)
else:
return filtered_ancestors


def get_function_signature(function, method=True):
wrapped = getattr(function, '_original_function', None)
if wrapped is None:
Expand Down Expand Up @@ -395,10 +370,6 @@ def get_function_signature(function, method=True):
signature = st[:-2] + ')'
else:
signature = st + ')'

if not method:
# Prepend the module name.
signature = clean_module_name(function.__module__) + '.' + signature
return post_process_signature(signature)


Expand All @@ -409,12 +380,15 @@ def get_class_signature(cls):
except (TypeError, AttributeError):
# in case the class inherits from object and does not
# define __init__
class_signature = clean_module_name(cls.__module__) + '.' + cls.__name__ + '()'
class_signature = "{clean_module_name}.{cls_name}()".format(
clean_module_name=clean_module_name(cls.__module__),
cls_name=cls.__name__
)
return post_process_signature(class_signature)


def post_process_signature(signature):
parts = re.split('\.(?!\d)', signature)
parts = re.split(r'\.(?!\d)', signature)
if len(parts) >= 4:
if parts[1] == 'layers':
signature = 'keras.layers.' + '.'.join(parts[3:])
Expand Down Expand Up @@ -459,7 +433,7 @@ def code_snippet(snippet):


def count_leading_spaces(s):
ws = re.search('\S', s)
ws = re.search(r'\S', s)
if ws:
return ws.start()
else:
Expand All @@ -468,7 +442,8 @@ def count_leading_spaces(s):

def process_list_block(docstring, starting_point, leading_spaces, marker):
ending_point = docstring.find('\n\n', starting_point)
block = docstring[starting_point:None if ending_point == -1 else ending_point - 1]
block = docstring[starting_point:(None if ending_point == -1 else
ending_point - 1)]
# Place marker for later reinjection.
docstring = docstring.replace(block, marker)
lines = block.split('\n')
Expand Down Expand Up @@ -596,7 +571,6 @@ def process_docstring(docstring):
shutil.copy(fpath, new_fpath)


# Take care of index page.
def read_file(path):
with open(path) as f:
return f.read()
Expand All @@ -616,16 +590,37 @@ def collect_class_methods(cls, methods):
def render_function(function, method=True):
subblocks = []
signature = get_function_signature(function, method=method)
signature = signature.replace(function.__module__ + '.', '')
level = 3
subblocks.append('#' * level + ' ' + function.__name__ + '\n')
if method:
signature = signature.replace(
clean_module_name(function.__module__) + '.', '')
subblocks.append('### ' + function.__name__ + '\n')
subblocks.append(code_snippet(signature))
docstring = function.__doc__
if docstring:
subblocks.append(process_docstring(docstring))
return '\n\n'.join(subblocks)


def read_page_data(page_data, type):
assert type in ['classes', 'functions', 'methods']
data = page_data.get(type, [])
for module in page_data.get('all_module_{}'.format(type), []):
module_data = []
for name in dir(module):
if name[0] == '_' or name in EXCLUDE:
continue
module_member = getattr(module, name)
if (inspect.isclass(module_member) and type == 'classes' or
inspect.isfunction(module_member) and type == 'functions'):
instance = module_member
if module.__name__ in instance.__module__:
if instance not in module_data:
module_data.append(instance)
module_data.sort(key=lambda x: id(x))
data += module_data
return data


if __name__ == '__main__':
readme = read_file('../README.md')
index = read_file('templates/index.md')
Expand All @@ -635,22 +630,9 @@ def render_function(function, method=True):

print('Generating docs for Keras %s.' % keras.__version__)
for page_data in PAGES:
blocks = []
classes = page_data.get('classes', [])
for module in page_data.get('all_module_classes', []):
module_classes = []
for name in dir(module):
if name[0] == '_' or name in EXCLUDE:
continue
module_member = getattr(module, name)
if inspect.isclass(module_member):
cls = module_member
if cls.__module__ == module.__name__:
if cls not in module_classes:
module_classes.append(cls)
module_classes.sort(key=lambda x: id(x))
classes += module_classes
classes = read_page_data(page_data, 'classes')

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

functions = page_data.get('functions', [])
for module in page_data.get('all_module_functions', []):
module_functions = []
for name in dir(module):
if name[0] == '_' or name in EXCLUDE:
continue
module_member = getattr(module, name)
if inspect.isfunction(module_member):
function = module_member
if module.__name__ in function.__module__:
if function not in module_functions:
module_functions.append(function)
module_functions.sort(key=lambda x: id(x))
functions += module_functions
methods = read_page_data(page_data, 'methods')

for method in methods:
blocks.append(render_function(method, method=True))

functions = read_page_data(page_data, 'functions')

for function in functions:
blocks.append(render_function(function, method=False))
Expand All @@ -706,7 +680,8 @@ def render_function(function, method=True):
if os.path.exists(path):
template = read_file(path)
assert '{{autogenerated}}' in template, ('Template found for ' + path +
' but missing {{autogenerated}} tag.')
' but missing {{autogenerated}}'
' tag.')
mkdown = template.replace('{{autogenerated}}', mkdown)
print('...inserting autogenerated content into template:', path)
else:
Expand Down
18 changes: 0 additions & 18 deletions docs/templates/applications.md
Original file line number Diff line number Diff line change
Expand Up @@ -533,15 +533,6 @@ MobileNet model, with weights pre-trained on ImageNet.

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

To load a MobileNet model via `load_model`, import the custom object `relu6` and pass it to the `custom_objects` parameter.

E.g.

```python
model = load_model('mobilenet.h5', custom_objects={
'relu6': mobilenet.relu6})
```

The default input size for this model is 224x224.

### Arguments
Expand Down Expand Up @@ -732,15 +723,6 @@ MobileNetV2 model, with weights pre-trained on ImageNet.

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

To load a MobileNetV2 model via `load_model`, import the custom object `relu6` and pass it to the `custom_objects` parameter.

E.g.

```python
model = load_model('mobilenet_v2.h5', custom_objects={
'relu6': mobilenetv2.relu6})
```

The default input size for this model is 224x224.

### Arguments
Expand Down
Loading

0 comments on commit 01d59d3

Please sign in to comment.