Created
June 6, 2018 17:26
-
-
Save hmaarrfk/b8fbe8a98b9c2322000ea89f34de13ef to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"cells": [ | |
{ | |
"cell_type": "code", | |
"execution_count": 2, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
"float64\n", | |
"float64\n", | |
"Profiling scipy.ndimage.convolve\n", | |
"3.96 µs ± 87.7 ns per loop (mean ± std. dev. of 7 runs, 100000 loops each)\n", | |
"118 ms ± 1.53 ms per loop (mean ± std. dev. of 7 runs, 10 loops each)\n", | |
"92.8 ms ± 536 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)\n" | |
] | |
} | |
], | |
"source": [ | |
"import numpy as np\n", | |
"\n", | |
"a = np.random.rand(2432, 4320)\n", | |
"K = np.random.rand(3, 3)\n", | |
"b = np.empty_like(a)\n", | |
"print(a.dtype)\n", | |
"print(K.dtype)\n", | |
"\n", | |
"from scipy.ndimage import convolve as ndconvolve\n", | |
"print('Profiling scipy.ndimage.convolve')\n", | |
"%timeit np.empty_like(a)\n", | |
"%timeit ndconvolve(a, K)\n", | |
"%timeit ndconvolve(a, K, output=b)" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 6, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
"Profiling scipy.signal.convolve2d\n", | |
"330 ms ± 3.44 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)\n" | |
] | |
} | |
], | |
"source": [ | |
"from scipy.signal import convolve2d\n", | |
"print('Profiling scipy.signal.convolve2d')\n", | |
"%timeit convolve2d(a, K)" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 7, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
"Profiling scipy.signal.fftconvolve\n", | |
"1.13 s ± 9.2 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)\n" | |
] | |
} | |
], | |
"source": [ | |
"print('Profiling scipy.signal.fftconvolve')\n", | |
"from scipy.signal import fftconvolve\n", | |
"%timeit fftconvolve(a, K)" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"metadata": {}, | |
"outputs": [], | |
"source": [] | |
} | |
], | |
"metadata": { | |
"kernelspec": { | |
"display_name": "Python 3", | |
"language": "python", | |
"name": "python3" | |
}, | |
"language_info": { | |
"codemirror_mode": { | |
"name": "ipython", | |
"version": 3 | |
}, | |
"file_extension": ".py", | |
"mimetype": "text/x-python", | |
"name": "python", | |
"nbconvert_exporter": "python", | |
"pygments_lexer": "ipython3", | |
"version": "3.6.5" | |
} | |
}, | |
"nbformat": 4, | |
"nbformat_minor": 2 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment