def test_invalid(self):
     lt = core.LabeledTensor(array_ops.reshape(math_ops.range(2), (1, 2)),
                             ['x', 'y'])
     with self.assertRaises(ValueError):
         core.impose_axis_order(lt)
     with self.assertRaises(ValueError):
         core.impose_axis_order(lt, ['x'])
Exemple #2
0
 def test_invalid(self):
   lt = core.LabeledTensor(
       array_ops.reshape(math_ops.range(2), (1, 2)), ['x', 'y'])
   with self.assertRaises(ValueError):
     core.impose_axis_order(lt)
   with self.assertRaises(ValueError):
     core.impose_axis_order(lt, ['x'])
Exemple #3
0
  def test_identity(self):
    axis_order = ['w', 'x', 'y', 'z']
    lt = core.LabeledTensor(tf.reshape(tf.range(24), (1, 2, 3, 4)), axis_order)
    actual = core.impose_axis_order(lt, axis_order)
    self.assertLabeledTensorsEqual(lt, actual)

    lt = core.LabeledTensor(tf.reshape(tf.range(6), (1, 2, 3)), axis_order[:3])
    actual = core.impose_axis_order(lt, axis_order)
    self.assertLabeledTensorsEqual(lt, actual)
    def test_identity(self):
        axis_order = ['w', 'x', 'y', 'z']
        lt = core.LabeledTensor(
            array_ops.reshape(math_ops.range(24), (1, 2, 3, 4)), axis_order)
        actual = core.impose_axis_order(lt, axis_order)
        self.assertLabeledTensorsEqual(lt, actual)

        lt = core.LabeledTensor(
            array_ops.reshape(math_ops.range(6), (1, 2, 3)), axis_order[:3])
        actual = core.impose_axis_order(lt, axis_order)
        self.assertLabeledTensorsEqual(lt, actual)
Exemple #5
0
  def test_reverse(self):
    axis_order = ['w', 'x', 'y', 'z']

    lt = core.LabeledTensor(tf.reshape(tf.range(24), (1, 2, 3, 4)), axis_order)
    actual = core.impose_axis_order(lt, axis_order[::-1])
    expected = core.transpose(lt, axis_order[::-1])
    self.assertLabeledTensorsEqual(expected, actual)

    lt = core.LabeledTensor(tf.reshape(tf.range(6), (1, 2, 3)), axis_order[:3])
    actual = core.impose_axis_order(lt, axis_order[::-1])
    expected = core.transpose(lt, ['y', 'x', 'w'])
    self.assertLabeledTensorsEqual(expected, actual)
    def test_reverse(self):
        axis_order = ['w', 'x', 'y', 'z']

        lt = core.LabeledTensor(
            array_ops.reshape(math_ops.range(24), (1, 2, 3, 4)), axis_order)
        actual = core.impose_axis_order(lt, axis_order[::-1])
        expected = core.transpose(lt, axis_order[::-1])
        self.assertLabeledTensorsEqual(expected, actual)

        lt = core.LabeledTensor(
            array_ops.reshape(math_ops.range(6), (1, 2, 3)), axis_order[:3])
        actual = core.impose_axis_order(lt, axis_order[::-1])
        expected = core.transpose(lt, ['y', 'x', 'w'])
        self.assertLabeledTensorsEqual(expected, actual)
Exemple #7
0
  def test_scope(self):
    axis_order = ['w', 'x', 'y', 'z']

    lt = core.LabeledTensor(tf.reshape(tf.range(24), (1, 2, 3, 4)), axis_order)
    expected = core.transpose(lt, axis_order[::-1])
    with core.axis_order_scope(axis_order[::-1]):
      actual = core.impose_axis_order(lt)
    self.assertLabeledTensorsEqual(expected, actual)
    def test_scope(self):
        axis_order = ['w', 'x', 'y', 'z']

        lt = core.LabeledTensor(
            array_ops.reshape(math_ops.range(24), (1, 2, 3, 4)), axis_order)
        expected = core.transpose(lt, axis_order[::-1])
        with core.axis_order_scope(axis_order[::-1]):
            actual = core.impose_axis_order(lt)
        self.assertLabeledTensorsEqual(expected, actual)