Ejemplo n.º 1
0
 def test_model(self):
   """Tests setting and getting model."""
   packed = packed_tensors.PackedTensors()
   packed.model = "xyz"
   packed = packed_tensors.PackedTensors(packed.string)
   self.assertEqual(packed.model, "xyz")
   del packed.model
Ejemplo n.º 2
0
 def test_set_get_model_identity(self):
     """Tests setting and getting model returns the same value."""
     packed = packed_tensors.PackedTensors()
     packed.model = "xyz"
     packed = packed_tensors.PackedTensors(packed.string)
     self.assertEqual(packed.model, "xyz")
     del packed.model
Ejemplo n.º 3
0
 def test_pack_unpack_identity(self):
     """Tests packing and unpacking tensors returns the same values."""
     string = tf.constant(["xyz"], dtype=tf.string)
     shape = tf.constant([1, 3], dtype=tf.int32)
     packed = packed_tensors.PackedTensors()
     packed.pack([string, shape])
     packed = packed_tensors.PackedTensors(packed.string)
     string_unpacked, shape_unpacked = packed.unpack([tf.string, tf.int32])
     self.assertAllEqual(string_unpacked, string)
     self.assertAllEqual(shape_unpacked, shape)
Ejemplo n.º 4
0
  def test_pack_unpack(self):
    """Tests packing and unpacking tensors."""
    string = np.array(["xyz".encode("ascii")], dtype=object)
    shape = np.array([1, 3], dtype=np.int32)
    arrays = [string, shape]

    string_t = tf.placeholder(tf.string, [1])
    shape_t = tf.placeholder(tf.int32, [2])
    tensors = [string_t, shape_t]

    packed = packed_tensors.PackedTensors()
    packed.pack(tensors, arrays)
    packed = packed_tensors.PackedTensors(packed.string)
    string_u, shape_u = packed.unpack(tensors)

    self.assertAllEqual(string_u, string)
    self.assertAllEqual(shape_u, shape)