예제 #1
0
 def test_cast(self):
     """Test that layers can automatically reshape inconsistent inputs."""
     value1 = np.random.uniform(size=(2, 1)).astype(np.float32)
     with self.session() as sess:
         out_tensor = Cast(dtype=tf.int32)(tf.constant(value1))
         result = out_tensor.eval()
         assert result.dtype == np.int32
예제 #2
0
 def test_cast(self):
   """Test that layers can automatically reshape inconsistent inputs."""
   value1 = np.random.uniform(size=(2, 1)).astype(np.float32)
   with self.session() as sess:
     out_tensor = Cast(dtype=tf.int32)(tf.constant(value1))
     result = out_tensor.eval()
     assert result.dtype == np.int32
예제 #3
0
def test_Cast_pickle():
  tg = TensorGraph()
  feature = Feature(shape=(tg.batch_size, 1))
  layer = Cast(in_layers=feature, dtype=tf.int32)
  tg.add_output(layer)
  tg.set_loss(layer)
  tg.build()
  tg.save()
예제 #4
0
  def create_loss(self, layer, label, weight):
    task_label = Squeeze(squeeze_dims=1, in_layers=[label])
    task_label = Cast(dtype=tf.int32, in_layers=[task_label])
    task_weight = Squeeze(squeeze_dims=1, in_layers=[weight])

    loss = SparseSoftMaxCrossEntropy(in_layers=[task_label, layer])
    weighted_loss = WeightedError(in_layers=[loss, task_weight])
    return weighted_loss