This repository has been archived by the owner on Jul 30, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #137 from fbcotter/tf
TF Functionality
- Loading branch information
Showing
25 changed files
with
4,964 additions
and
41 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
# IMPORTANT: before release, remove the 'devN' tag from the release name | ||
__version__ = '0.12.0dev1' | ||
__version__ = '0.13.0dev1' |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
""" | ||
Provide low-level Tensorflow accelerated operations. This backend requires that | ||
Tensorflow be installed. Works best with a GPU but still offers good | ||
improvements with a CPU. | ||
""" | ||
|
||
from .common import Pyramid | ||
from .transform1d import Transform1d | ||
from .transform2d import Transform2d | ||
|
||
__all__ = [ | ||
'Pyramid', | ||
'Transform1d', | ||
'Transform2d', | ||
] |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
from __future__ import absolute_import | ||
|
||
try: | ||
import tensorflow as tf | ||
except ImportError: | ||
# The lack of tensorflow will be caught by the low-level routines. | ||
pass | ||
|
||
|
||
class Pyramid(object): | ||
"""A tensorflow representation of a transform domain signal. | ||
An interface-compatible version of | ||
:py:class:`dtcwt.Pyramid` where the initialiser | ||
arguments are assumed to be :py:class:`tf.Variable` instances. | ||
The attributes defined in :py:class:`dtcwt.Pyramid` | ||
are implemented via properties. The original tf arrays may be accessed | ||
via the ``..._op(s)`` attributes. | ||
.. py:attribute:: lowpass_op | ||
A tensorflow tensor that can be evaluated in a session to return | ||
the coarsest scale lowpass signal for the input, X. | ||
.. py:attribute:: highpasses_op | ||
A tuple of tensorflow tensors, where each element is the complex | ||
subband coefficients for corresponding scales finest to coarsest. | ||
.. py:attribute:: scales_ops | ||
*(optional)* A tuple where each element is a tensorflow tensor | ||
containing the lowpass signal for corresponding scales finest to | ||
coarsest. This is not required for the inverse and may be *None*. | ||
""" | ||
def __init__(self, lowpass, highpasses, scales=None, numpy=False): | ||
self.lowpass_op = lowpass | ||
self.highpasses_ops = highpasses | ||
self.scales_ops = scales | ||
self.numpy = numpy | ||
|
||
@property | ||
def lowpass(self): | ||
if not hasattr(self, '_lowpass'): | ||
if self.lowpass_op is None: | ||
self._lowpass = None | ||
else: | ||
with tf.Session() as sess: | ||
sess.run(tf.global_variables_initializer()) | ||
self._lowpass = sess.run(self.lowpass_op) | ||
return self._lowpass | ||
|
||
@property | ||
def highpasses(self): | ||
if not hasattr(self, '_highpasses'): | ||
if self.highpasses_ops is None: | ||
self._highpasses = None | ||
else: | ||
with tf.Session() as sess: | ||
sess.run(tf.global_variables_initializer()) | ||
self._highpasses = \ | ||
tuple(sess.run(x) for x in self.highpasses_ops) | ||
return self._highpasses | ||
|
||
@property | ||
def scales(self): | ||
if not hasattr(self, '_scales'): | ||
if self.scales_ops is None: | ||
self._scales = None | ||
else: | ||
with tf.Session() as sess: | ||
sess.run(tf.global_variables_initializer()) | ||
self._scales = tuple(sess.run(x) for x in self.scales_ops) | ||
return self._scales |
Oops, something went wrong.