예제 #1
0
    def testDefaultJoinAlignmentError(self):
        pt1 = self.Wrap(numpy.array([[1.0], [2.0]]))
        pt2 = self.Wrap(numpy.array([[2.0, 3.0], [4.0, 5.0]]))
        pt3 = self.Wrap(numpy.array([5.0, 6.0]))

        with self.assertRaises(ValueError):
            prettytensor.join_pretty_tensors([pt1, pt2, pt3], pt1)
  def testDefaultJoinAlignmentError(self):
    pt1 = self.Wrap(numpy.array([[1.0], [2.0]]))
    pt2 = self.Wrap(numpy.array([[2.0, 3.0], [4.0, 5.0]]))
    pt3 = self.Wrap(numpy.array([5.0, 6.0]))

    with self.assertRaises(ValueError):
      prettytensor.join_pretty_tensors([pt1, pt2, pt3], pt1)
    def testCustomJoin(self):
        pt1 = self.Wrap(numpy.array([[1.0], [2.0]]))
        pt2 = self.Wrap(numpy.array([[2.0], [4.0]]))
        pt3 = self.Wrap(numpy.array([[5.0], [6.0]]))
        out_pt = prettytensor.join_pretty_tensors([pt1, pt2, pt3], pt1, join_function=tf.add_n)

        out = self.RunTensor(out_pt)

        testing.assert_allclose(out, numpy.array([[8.0], [12.0]]), rtol=TOLERANCE)
    def testDefaultJoinFunction(self):
        pt1 = self.Wrap(numpy.array([[1.0], [2.0]]))
        pt2 = self.Wrap(numpy.array([[2.0, 3.0], [4.0, 5.0]]))
        pt3 = self.Wrap(numpy.array([[5.0], [6.0]]))
        out_pt = prettytensor.join_pretty_tensors([pt1, pt2, pt3], pt1)

        out = self.RunTensor(out_pt)

        testing.assert_allclose(out, numpy.array([[1.0, 2.0, 3.0, 5.0], [2.0, 4.0, 5.0, 6.0]]), rtol=TOLERANCE)
예제 #5
0
  def testCustomJoin(self):
    pt1 = self.Wrap(numpy.array([[1.0], [2.0]]))
    pt2 = self.Wrap(numpy.array([[2.0], [4.0]]))
    pt3 = self.Wrap(numpy.array([[5.0], [6.0]]))
    out_pt = prettytensor.join_pretty_tensors(
        [pt1, pt2, pt3], pt1, join_function=tf.add_n)

    out = self.RunTensor(out_pt)

    testing.assert_allclose(out, numpy.array([[8.0], [12.0]]), rtol=TOLERANCE)
예제 #6
0
  def testDefaultJoinFunction(self):
    pt1 = self.Wrap(numpy.array([[1.0], [2.0]]))
    pt2 = self.Wrap(numpy.array([[2.0, 3.0], [4.0, 5.0]]))
    pt3 = self.Wrap(numpy.array([[5.0], [6.0]]))
    out_pt = prettytensor.join_pretty_tensors([pt1, pt2, pt3], pt1)

    out = self.RunTensor(out_pt)

    testing.assert_allclose(
        out, numpy.array([[1.0, 2.0, 3.0, 5.0], [2.0, 4.0, 5.0, 6.0]]),
        rtol=TOLERANCE)