Skip to content

Commit

Permalink
removed data manager from utils
Browse files Browse the repository at this point in the history
  • Loading branch information
amock committed Mar 6, 2018
2 parents e5986c1 + 5a3d0cf commit 3510e1c
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 25 deletions.
32 changes: 16 additions & 16 deletions model.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@ class VOModel(object):
Attributes
----------
input_images : tf.Placeholder
Float placeholder with shape (batch_size, sequence_length, h, w, c * 2).
Float placeholder with shape ``(batch_size, sequence_length, h, w, c * 2)``.
This tensor contains the stacked input images.
target_poses : tf.Placeholder
Float placeholder of shape (batch_size, sequence_length, 6) with 3
Float placeholder of shape ``(batch_size, sequence_length, 6)`` with 3
translational and 3 rotational components
lstm_states : tf.Placeholder
Float placeholder used to feed the initial lstm state into the network. The shape
is (2, 2, batch_size, memory_size) since we have 2 lstm cells and cell and hidden
is ``(2, 2, batch_size, memory_size)`` since we have 2 lstm cells and cell and hidden
states are contained in this tensor. THE CELL STATE (TUPLE MEMBER H) MUST COME
BEFORE THE HIDDEN STATE (TUPLE MEMBER C).
sequence_length : int
Expand Down Expand Up @@ -284,12 +284,12 @@ def get_rnn_output(self, session, input_batch, pose_batch, initial_states=None):
session : tf.Session
Session to execute op in
input_batch : np.ndarray
Array of shape (batch_size, sequence_length, h, w, 6) where two consecutive
Array of shape ``(batch_size, sequence_length, h, w, 6)`` where two consecutive
rgb images are stacked together.
pose_batch : np.ndarray
Array of shape (batch_size, sequence_length, 6) with Poses
Array of shape ``(batch_size, sequence_length, 6)`` with Poses
initial_states : np.ndarray
Array of shape (2, 2, batch_size, memory_size)
Array of shape ``(2, 2, batch_size, memory_size)``
Returns
-------
Expand All @@ -310,10 +310,10 @@ def get_cnn_output(self, session, input_batch, pose_batch):
session : tf.Session
Session to execute op in
input_batch : np.ndarray
Array of shape (batch_size, sequence_length, h, w, 6) where two consecutive
Array of shape ``(batch_size, sequence_length, h, w, 6)`` where two consecutive
rgb images are stacked together.
pose_batch : np.ndarray
Array of shape (batch_size, sequence_length, 6) with Poses
Array of shape ``(batch_size, sequence_length, 6)`` with Poses
Returns
-------
Expand All @@ -331,14 +331,14 @@ def train(self, session, input_batch, pose_batch, initial_states=None, return_pr
Parameters
----------
session : tf.Session
Session to execute op in
Session to execute op in
input_batch : np.ndarray
Array of shape (batch_size, sequence_length, h, w, 6) where two consecutive
rgb images are stacked together.
Array of shape ``(batch_size, sequence_length, h, w, 6)`` where two consecutive
rgb images are stacked together.
pose_batch : np.ndarray
Array of shape (batch_size, sequence_length, 6) with Poses
initial_states : np.ndarray
Array of shape (2, 2, batch_size, memory_size)
Array of shape ``(batch_size, sequence_length, 6)`` with Poses
initial_states : np.ndarray
Array of shape ``(2, 2, batch_size, memory_size)``
Returns
-------
Expand Down Expand Up @@ -388,10 +388,10 @@ def test(self, session, input_batch, pose_batch, initial_states=None):
session : tf.Session
Session to run ops in
input_batch : np.ndarray
Array of shape (batch_size, sequence_length, h, w, 6) where two consecutive
Array of shape ``(batch_size, sequence_length, h, w, 6)`` where two consecutive
rgb images are stacked together.
pose_batch : np.ndarray
Array of shape (batch_size, sequence_length, 6) with Poses
Array of shape ``(batch_size, sequence_length, 6)`` with Poses
'''
batch_size = input_batch.shape[0]

Expand Down
19 changes: 10 additions & 9 deletions utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,18 @@
def tensor_from_lstm_tuple(tuples, validate_shape=False):
'''Create a tensor from a tuple of :py:class:`tf.contrib.rnn.LSTMStateTuple` s.
.. note:: Error checks
.. note::
We do not check all possible error cases. For instance, the different LSTMStateTuples could
not only have differing shapes (which we check for to some extend see ``validate_shape``
not only have differing shapes (which we check for to some extent see ``validate_shape``
parameter), but also the state members ``c`` and ``h`` could differ in their data type (Tensor,
array), which we *do not* check.
Parameters
----------
tuples : tuple(LSTMStateTuple)
Tuple of N_lstm ``LSTMStateTuple`` s where each of the tuples has members of shape
``(batch_size, memory_size)``
Tuple of ``LSTMStateTuple`` s (as many as there are stacked lstm cells) where each
of the tuples has members of shape ``(batch_size, memory_size)``
validate_shape : bool
Enforce identical shapes of all cell and memory states. This entails that
all dimensions must be known. When using variable batch size, set to
Expand Down Expand Up @@ -130,7 +130,7 @@ def resize_to_multiple(images, multiples):
Parameters
----------
images : tf.Tensor
Tensor of shape [batch, height, width, channels]
Tensor of shape ``(batch, height, width, channels)``
multiples : int or tuple
The value/s that should evenly divide the resized image's dimensions
Expand All @@ -154,21 +154,21 @@ def image_pairs(image_sequence, sequence_length):
6-channel image. If the image sequence length is not evenly divided by the sequence length,
fewer than the total number of images will be yielded.
.. note:: Deprecated
.. note::
This function is deprecated by :py:class:`DataManager`
Parameters
----------
image_sequence : np.ndarray
Array of shape (num, h, w, 3)
Array of shape ``(num, h, w, 3)``
sequence_length : int
Number of elements (6-channel imgs) yielded each time
Returns
-------
np.ndarray
Array of shape (sequence_length, h, w, 6)
Array of shape ``(sequence_length, h, w, 6)``
'''
N, h, w, c = image_sequence.shape
for idx in range(0, N, sequence_length):
Expand Down Expand Up @@ -200,7 +200,7 @@ def compute_rgb_mean(image_sequence):
Parameters
----------
image_sequence : np.ndarray
Array of shape (N, h, w, c) or (h, w, c)
Array of shape ``(N, h, w, c)`` or ``(h, w, c)``
'''
if image_sequence.ndim == 4:
_, h, w, c = image_sequence.shape
Expand Down Expand Up @@ -237,6 +237,7 @@ def convert_large_array(file_in, file_out, dtype, factor=1.0):
if factor != 1.0:
np.multiply(dest, factor, out=dest)


def subtract_poses(pose_x, pose_y):
'''Correct subtraction of two poses
Expand Down

0 comments on commit 3510e1c

Please sign in to comment.