awslabs / keras-apache-mxnet

[DEPRECATED] Amazon Deep Learning's Keras with Apache MXNet support
https://github.com/awslabs/keras-apache-mxnet/wiki
Other
290 stars 65 forks source link

Fix sparse benchmark #170

Closed kalyc closed 6 years ago

kalyc commented 6 years ago

Summary

Keras-MXNet benchmark script resulted in segmentation fault error initially. Added check to ensure that it doesn't happen.

Note - Benchmark script currently works well only with batch size <= (10) train_data.shape[1] size

For dimensions > 10 this is the error we get - File "benchmark/sparse/linear_regression/run_sparse_benchmark.py", line 40, in <module> invoke_benchmark(args.batch, args.epochs) File "benchmark/sparse/linear_regression/run_sparse_benchmark.py", line 25, in invoke_benchmark epochs=int(epochs)) File "/Users/kalyanee/Documents/kalyc-keras-1/keras-apache-mxnet/benchmark/sparse/linear_regression/keras_sparse_model.py", line 26, in run_benchmark batch_size=batch_size) File "/anaconda2/envs/mxnet/lib/python3.4/site-packages/keras_mxnet-2.2.2-py3.4.egg/keras/engine/training.py", line 1037, in fit File "/anaconda2/envs/mxnet/lib/python3.4/site-packages/keras_mxnet-2.2.2-py3.4.egg/keras/engine/training_arrays.py", line 199, in fit_loop File "/anaconda2/envs/mxnet/lib/python3.4/site-packages/keras_mxnet-2.2.2-py3.4.egg/keras/backend/mxnet_backend.py", line 4982, in train_function File "/anaconda2/envs/mxnet/lib/python3.4/site-packages/keras_mxnet-2.2.2-py3.4.egg/keras/backend/mxnet_backend.py", line 4942, in _adjust_module File "/anaconda2/envs/mxnet/lib/python3.4/site-packages/mxnet/module/module.py", line 471, in reshape self._exec_group.reshape(self._data_shapes, self._label_shapes) File "/anaconda2/envs/mxnet/lib/python3.4/site-packages/mxnet/module/executor_group.py", line 382, in reshape self.bind_exec(data_shapes, label_shapes, reshape=True) File "/anaconda2/envs/mxnet/lib/python3.4/site-packages/mxnet/module/executor_group.py", line 358, in bind_exec allow_up_sizing=True, **dict(data_shapes_i + label_shapes_i)) File "/anaconda2/envs/mxnet/lib/python3.4/site-packages/mxnet/executor.py", line 423, in reshape new_arg_dict[name] = arr.reshape(new_shape) File "/anaconda2/envs/mxnet/lib/python3.4/site-packages/mxnet/ndarray/sparse.py", line 157, in reshape raise NotSupportedForSparseNDArray(self.reshape, None, shape) mxnet.base.NotSupportedForSparseNDArray: Function reshape with arguments (<class 'tuple'>) is not supported for SparseNDArray and only available in NDArray.

Related Issues

PR Overview

Solution

Added workaround for the reshape error by slicing data before training