class_docstr: Testing objective functions from tflearn/objectives
docstr: Test tflearn.objectives.weak_cross_entropy_2d
docstr_tok: ["Test","tflearn.objectives.weak_cross_entropy_2d"]
code: def test_weak_cross_entropy_2d(self):
      """
      Test tflearn.objectives.weak_cross_entropy_2d
      """
      num_classes = 2
      batch_size = 3
      height, width = 5, 5
      shape = (batch_size, height, width, num_classes)
      y_pred = np.random.random(shape).astype(np.float32)
      target = np.random.randint(0, num_classes, np.prod(shape[:-1]))
      # convert to one-hot encoding
      y_true = np.eye(num_classes)[target].reshape(shape)
  
      with tf.Graph().as_default():
          y_pred = tf.convert_to_tensor(y_pred)
          y_true = tf.convert_to_tensor(y_true)
  
          loss = tflearn.objectives.weak_cross_entropy_2d(
              y_pred, y_true
          )
  
          with tf.Session() as sess:
              res = sess.run(loss)
  
      self.assertGreater(res, 0.0)
      self.assertLess(res, 1.0)
  
imports: import tflearn
  import unittest
  import numpy
  import tensorflow.compat.v1
label_desc: Use image node_id 1 for calling the TestObjectives obj's underlying member method code with example usage: obj.test_weak_cross_entropy_2d() without return types