Пример #1
0
  def generate_testdata(self):
    ops.reset_default_graph()
    sess = session.Session()
    placeholder = array_ops.placeholder(dtypes.string)
    summary_tensor = text_summary.text_summary('message', placeholder)

    vector_summary = text_summary.text_summary('vector', placeholder)

    run_names = ['fry', 'leela']
    for run_name in run_names:
      subdir = os.path.join(self.logdir, run_name)
      writer = summary.FileWriter(subdir)
      writer.add_graph(sess.graph)

      step = 0
      for gem in GEMS:
        message = run_name + ' *loves* ' + gem
        feed_dict = {placeholder: message}
        summ = sess.run(summary_tensor, feed_dict=feed_dict)
        writer.add_summary(summ, global_step=step)
        step += 1

      vector_message = ['one', 'two', 'three', 'four']
      summ = sess.run(vector_summary, feed_dict={placeholder: vector_message})
      writer.add_summary(summ)
      writer.close()
Пример #2
0
  def generate_testdata(self):
    ops.reset_default_graph()
    sess = session.Session()
    placeholder = array_ops.placeholder(dtypes.string)
    summary_tensor = text_summary.text_summary('message', placeholder)

    vector_summary = text_summary.text_summary('vector', placeholder)

    run_names = ['fry', 'leela']
    for run_name in run_names:
      subdir = os.path.join(self.logdir, run_name)
      writer = summary.FileWriter(subdir)
      writer.add_graph(sess.graph)

      step = 0
      for gem in GEMS:
        message = run_name + ' *loves* ' + gem
        feed_dict = {placeholder: message}
        summ = sess.run(summary_tensor, feed_dict=feed_dict)
        writer.add_summary(summ, global_step=step)
        step += 1

      vector_message = ['one', 'two', 'three', 'four']
      summ = sess.run(vector_summary, feed_dict={placeholder: vector_message})
      writer.add_summary(summ)
      writer.close()
Пример #3
0
    def testTextSummaryAPI(self):
        with self.test_session():

            with self.assertRaises(ValueError):
                num = array_ops.constant(1)
                text_summary.text_summary("foo", num)

            with self.assertRaises(ValueError):
                arr = array_ops.constant(["one", "two", "three"])
                text_summary.text_summary("foo", arr)

            summ = text_summary.text_summary("foo", array_ops.constant("one"))
            self.assertEqual(summ.op.type, "TensorSummary")
  def testTextSummaryAPI(self):
    with self.test_session():

      with self.assertRaises(ValueError):
        num = array_ops.constant(1)
        text_summary.text_summary("foo", num)

      with self.assertRaises(ValueError):
        arr = array_ops.constant(["one", "two", "three"])
        text_summary.text_summary("foo", arr)

      summ = text_summary.text_summary("foo", array_ops.constant("one"))
      self.assertEqual(summ.op.type, "TensorSummary")
Пример #5
0
  def testTextSummaryAPI(self):
    with self.cached_session():

      with self.assertRaises(ValueError):
        num = array_ops.constant(1)
        text_summary.text_summary("foo", num)

      # The API accepts vectors.
      arr = array_ops.constant(["one", "two", "three"])
      summ = text_summary.text_summary("foo", arr)
      self.assertEqual(summ.op.type, "TensorSummaryV2")

      # the API accepts scalars
      summ = text_summary.text_summary("foo", array_ops.constant("one"))
      self.assertEqual(summ.op.type, "TensorSummaryV2")
Пример #6
0
    def testTextSummaryAPI(self):
        with self.cached_session():

            with self.assertRaises(ValueError):
                num = array_ops.constant(1)
                text_summary.text_summary("foo", num)

            # The API accepts vectors.
            arr = array_ops.constant(["one", "two", "three"])
            summ = text_summary.text_summary("foo", arr)
            self.assertEqual(summ.op.type, "TensorSummaryV2")

            # the API accepts scalars
            summ = text_summary.text_summary("foo", array_ops.constant("one"))
            self.assertEqual(summ.op.type, "TensorSummaryV2")
Пример #7
0
  def testTextSummaryAPI(self):
    with self.test_session():

      with self.assertRaises(ValueError):
        num = array_ops.constant(1)
        text_summary.text_summary("foo", num)

      with self.assertRaises(ValueError):
        arr = array_ops.constant(["one", "two", "three"])
        text_summary.text_summary("foo", arr)

      summ = text_summary.text_summary("foo", array_ops.constant("one"))
      self.assertEqual(summ.op.type, "TensorSummary")

      text_summary.text_summary("bar", array_ops.constant("2"), collections=[])
      summaries = framework_ops.get_collection(
          framework_ops.GraphKeys.SUMMARIES)
      self.assertEqual(len(summaries), 1)
  def generate_testdata(self):
    ops.reset_default_graph()
    sess = session.Session()
    placeholder = array_ops.placeholder(dtypes.string, shape=[])
    summary_tensor = text_summary.text_summary("message", placeholder)

    run_names = ["fry", "leela"]
    for run_name in run_names:
      subdir = os.path.join(self.logdir, run_name)
      writer = summary.FileWriter(subdir)
      writer.add_graph(sess.graph)

      step = 0
      for gem in GEMS:
        message = run_name + " loves " + gem
        feed_dict = {placeholder: message}
        summ = sess.run(summary_tensor, feed_dict=feed_dict)
        writer.add_summary(summ, global_step=step)
        step += 1
      writer.close()
Пример #9
0
    def generate_testdata(self):
        ops.reset_default_graph()
        sess = session.Session()
        placeholder = array_ops.placeholder(dtypes.string, shape=[])
        summary_tensor = text_summary.text_summary("message", placeholder)

        run_names = ["fry", "leela"]
        for run_name in run_names:
            subdir = os.path.join(self.logdir, run_name)
            writer = summary.FileWriter(subdir)
            writer.add_graph(sess.graph)

            step = 0
            for gem in GEMS:
                message = run_name + " *loves* " + gem
                feed_dict = {placeholder: message}
                summ = sess.run(summary_tensor, feed_dict=feed_dict)
                writer.add_summary(summ, global_step=step)
                step += 1
            writer.close()
Пример #10
0
    def testTextSummaryAPI(self):
        with self.test_session():

            with self.assertRaises(ValueError):
                num = array_ops.constant(1)
                text_summary.text_summary("foo", num)

            with self.assertRaises(ValueError):
                arr = array_ops.constant(["one", "two", "three"])
                text_summary.text_summary("foo", arr)

            summ = text_summary.text_summary("foo", array_ops.constant("one"))
            self.assertEqual(summ.op.type, "TensorSummary")

            text_summary.text_summary("bar",
                                      array_ops.constant("2"),
                                      collections=[])
            summaries = framework_ops.get_collection(
                framework_ops.GraphKeys.SUMMARIES)
            self.assertEqual(len(summaries), 1)
Пример #11
0
 def testTextSummaryCollections(self):
   text_summary.text_summary("bar", array_ops.constant("2"), collections=[])
   summaries = framework_ops.get_collection(framework_ops.GraphKeys.SUMMARIES)
   self.assertEqual(len(summaries), 0)