diff --git a/model.py b/model.py index 10adc4b..1d39074 100644 --- a/model.py +++ b/model.py @@ -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 @@ -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 ------- @@ -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 ------- @@ -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 ------- @@ -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] diff --git a/utils.py b/utils.py index b12b3f9..80a8782 100644 --- a/utils.py +++ b/utils.py @@ -13,9 +13,9 @@ 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. @@ -23,8 +23,8 @@ def tensor_from_lstm_tuple(tuples, validate_shape=False): 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 @@ -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 @@ -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): @@ -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 @@ -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