当前位置: 首页>>代码示例>>Python>>正文


Python plugin_asset.get_plugin_asset函数代码示例

本文整理汇总了Python中tensorflow.python.summary.plugin_asset.get_plugin_asset函数的典型用法代码示例。如果您正苦于以下问题:Python get_plugin_asset函数的具体用法?Python get_plugin_asset怎么用?Python get_plugin_asset使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了get_plugin_asset函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: testGetPluginAsset

 def testGetPluginAsset(self):
   epa = plugin_asset.get_plugin_asset(_ExamplePluginAsset)
   self.assertIsInstance(epa, _ExamplePluginAsset)
   epa2 = plugin_asset.get_plugin_asset(_ExamplePluginAsset)
   self.assertIs(epa, epa2)
   opa = plugin_asset.get_plugin_asset(_OtherExampleAsset)
   self.assertIsNot(epa, opa)
开发者ID:1000sprites,项目名称:tensorflow,代码行数:7,代码来源:plugin_asset_test.py

示例2: testRespectsGraphArgument

  def testRespectsGraphArgument(self):
    g1 = ops.Graph()
    g2 = ops.Graph()
    e1 = plugin_asset.get_plugin_asset(_ExamplePluginAsset, g1)
    e2 = plugin_asset.get_plugin_asset(_ExamplePluginAsset, g2)

    self.assertEqual(e1, plugin_asset.get_all_plugin_assets(g1)[0])
    self.assertEqual(e2, plugin_asset.get_all_plugin_assets(g2)[0])
开发者ID:1000sprites,项目名称:tensorflow,代码行数:8,代码来源:plugin_asset_test.py

示例3: testEndpointsNoAssets

  def testEndpointsNoAssets(self):
    g = ops.Graph()
    with g.as_default():
      plugin_asset.get_plugin_asset(projector_plugin.ProjectorPluginAsset)

    fw = writer.FileWriter(self.log_dir, graph=g)
    fw.close()

    self._SetupWSGIApp()
    run_json = self._GetJson('/data/plugin/projector/runs')
    self.assertEqual(run_json, [])
开发者ID:chenjun0210,项目名称:tensorflow,代码行数:11,代码来源:projector_plugin_test.py

示例4: testSimplePluginCase

 def testSimplePluginCase(self):
   tempdir = self.get_temp_dir()
   with ops.Graph().as_default() as g:
     plugin_asset.get_plugin_asset(PluginAlpha)
     fw = writer.FileWriter(tempdir)
     fw.add_graph(g)
   self.assertEqual(["Alpha"], plugin_asset_util.ListPlugins(tempdir))
   assets = plugin_asset_util.ListAssets(tempdir, "Alpha")
   self.assertEqual(["contents.txt"], assets)
   contents = plugin_asset_util.RetrieveAsset(tempdir, "Alpha", "contents.txt")
   self.assertEqual("hello world", contents)
开发者ID:LUTAN,项目名称:tensorflow,代码行数:11,代码来源:plugin_asset_util_test.py

示例5: testNoAssetsProperSerializationOnDisk

  def testNoAssetsProperSerializationOnDisk(self):
    logdir = self.get_temp_dir()
    plugin_dir = os.path.join(logdir, writer._PLUGINS_DIR,
                              projector_plugin.ProjectorPluginAsset.plugin_name)

    with ops.Graph().as_default() as g:
      plugin_asset.get_plugin_asset(projector_plugin.ProjectorPluginAsset)
      fw = writer.FileWriter(logdir)
      fw.add_graph(g)

    with gfile.Open(os.path.join(plugin_dir, 'projector_config.pbtxt')) as f:
      content = f.read()
    self.assertEqual(content, '')
开发者ID:LugarkPirog,项目名称:tensorflow,代码行数:13,代码来源:projector_plugin_test.py

示例6: testAddEmbeddingThumbnailListEntriesNot3DTensors

  def testAddEmbeddingThumbnailListEntriesNot3DTensors(self):
    manager = plugin_asset.get_plugin_asset(
        projector_plugin.ProjectorPluginAsset)

    with self.assertRaises(ValueError):
      manager.add_embedding('test3', np.array([[1]]), thumbnails=[[1, 2, 3]],
                            thumbnail_dim=[1, 1])
开发者ID:chenjun0210,项目名称:tensorflow,代码行数:7,代码来源:projector_plugin_test.py

示例7: testEndpointsMetadataForVariableAssets

  def testEndpointsMetadataForVariableAssets(self):
    self._GenerateProjectorTestData()
    g = ops.Graph()
    with g.as_default():
      manager = plugin_asset.get_plugin_asset(
          projector_plugin.ProjectorPluginAsset)

    metadata = projector_plugin.EmbeddingMetadata(3)
    metadata.add_column('labels', ['a', 'b', 'c'])
    manager.add_metadata_for_embedding_variable('test', metadata)

    fw = writer.FileWriter(self.log_dir, graph=g)
    fw.close()

    self._SetupWSGIApp()
    run_json = self._GetJson('/data/plugin/projector/runs')
    self.assertTrue(run_json)

    run = run_json[0]
    metedata_query = '/data/plugin/projector/metadata?run=%s&name=test' % run
    metadata_tsv = self._Get(metedata_query).data
    self.assertEqual(metadata_tsv, b'a\nb\nc\n')

    unk_tensor_query = '/data/plugin/projector/tensor?run=%s&name=test' % run
    response = self._Get(unk_tensor_query)
    self.assertEqual(response.status_code, 400)

    expected_tensor = np.array([[6, 6]], dtype=np.float32)
    tensor_query = '/data/plugin/projector/tensor?run=%s&name=var1' % run
    tensor_bytes = self._Get(tensor_query).data
    self._AssertTensorResponse(tensor_bytes, expected_tensor)
开发者ID:chenjun0210,项目名称:tensorflow,代码行数:31,代码来源:projector_plugin_test.py

示例8: text_summary

def text_summary(name, tensor, collections=None):
  """Summarizes textual data.

  Text data summarized via this plugin will be visible in the Text Dashboard
  in TensorBoard.

  Args:
    name: A name for the generated node. Will also serve as a series name in
      TensorBoard.
    tensor: a scalar string-type Tensor to summarize.
    collections: Optional list of ops.GraphKeys.  The collections to add the
      summary to.  Defaults to [_ops.GraphKeys.SUMMARIES]

  Returns:
    A  TensorSummary op that is configured so that TensorBoard will recognize
    that it contains textual data. The TensorSummary is a scalar `Tensor` of
    type `string` which contains `Summary` protobufs.

  Raises:
    ValueError: If tensor has the wrong shape or type.
  """
  if tensor.dtype != dtypes.string:
    raise ValueError("Expected tensor %s to have dtype string, got %s" %
                     (tensor.name, tensor.dtype))

  if tensor.shape.ndims != 0:
    raise ValueError("Expected tensor %s to be scalar, has shape %s" %
                     (tensor.name, tensor.shape))

  t_summary = tensor_summary(name, tensor, collections=collections)
  text_assets = plugin_asset.get_plugin_asset(TextSummaryPluginAsset)
  text_assets.register_tensor(t_summary.op.name)
  return t_summary
开发者ID:LugarkPirog,项目名称:tensorflow,代码行数:33,代码来源:text_summary.py

示例9: testEndpointsComboTensorAssetsAndCheckpoint

  def testEndpointsComboTensorAssetsAndCheckpoint(self):
    self._GenerateProjectorTestData()
    g = ops.Graph()
    with g.as_default():
      manager = plugin_asset.get_plugin_asset(
          projector_plugin.ProjectorPluginAsset)

    metadata = projector_plugin.EmbeddingMetadata(3)
    metadata.add_column('labels', ['a', 'b', 'c'])
    manager.add_metadata_for_embedding_variable('var1', metadata)

    new_tensor_values = np.array([[1, 2], [3, 4], [5, 6]])
    manager.add_embedding('new_tensor', new_tensor_values)

    fw = writer.FileWriter(self.log_dir, graph=g)
    fw.close()

    self._SetupWSGIApp()
    run_json = self._GetJson('/data/plugin/projector/runs')
    self.assertTrue(run_json)

    run = run_json[0]
    var1_values = np.array([[6, 6]], dtype=np.float32)
    var1_tensor_query = '/data/plugin/projector/tensor?run=%s&name=var1' % run
    tensor_bytes = self._Get(var1_tensor_query).data
    self._AssertTensorResponse(tensor_bytes, var1_values)

    metadata_query = '/data/plugin/projector/metadata?run=%s&name=var1' % run
    metadata_tsv = self._Get(metadata_query).data
    self.assertEqual(metadata_tsv, b'a\nb\nc\n')

    tensor_query = '/data/plugin/projector/tensor?run=%s&name=new_tensor' % run
    tensor_bytes = self._Get(tensor_query).data
    self._AssertTensorResponse(tensor_bytes, new_tensor_values)
开发者ID:chenjun0210,项目名称:tensorflow,代码行数:34,代码来源:projector_plugin_test.py

示例10: testAddEmbeddingThumbnailListNotOfRank4

  def testAddEmbeddingThumbnailListNotOfRank4(self):
    manager = plugin_asset.get_plugin_asset(
        projector_plugin.ProjectorPluginAsset)

    with self.assertRaises(ValueError):
      manager.add_embedding('test2', np.array([[1]]),
                            thumbnails=np.array([[1]]), thumbnail_dim=[1, 1])
开发者ID:chenjun0210,项目名称:tensorflow,代码行数:7,代码来源:projector_plugin_test.py

示例11: text_summary

def text_summary(name, tensor, collections=None):
  """Summarizes textual data.

  Text data summarized via this plugin will be visible in the Text Dashboard
  in TensorBoard. The standard TensorBoard Text Dashboard will render markdown
  in the strings, and will automatically organize 1d and 2d tensors into tables.
  If a tensor with more than 2 dimensions is provided, a 2d subarray will be
  displayed along with a warning message. (Note that this behavior is not
  intrinsic to the text summary api, but rather to the default TensorBoard text
  plugin.)

  Args:
    name: A name for the generated node. Will also serve as a series name in
      TensorBoard.
    tensor: a string-type Tensor to summarize.
    collections: Optional list of ops.GraphKeys.  The collections to add the
      summary to.  Defaults to [_ops.GraphKeys.SUMMARIES]

  Returns:
    A  TensorSummary op that is configured so that TensorBoard will recognize
    that it contains textual data. The TensorSummary is a scalar `Tensor` of
    type `string` which contains `Summary` protobufs.

  Raises:
    ValueError: If tensor has the wrong type.
  """
  if tensor.dtype != dtypes.string:
    raise ValueError("Expected tensor %s to have dtype string, got %s" %
                     (tensor.name, tensor.dtype))

  t_summary = tensor_summary(name, tensor, collections=collections)
  text_assets = plugin_asset.get_plugin_asset(TextSummaryPluginAsset)
  text_assets.register_tensor(t_summary.op.name)
  return t_summary
开发者ID:AlbertXiebnu,项目名称:tensorflow,代码行数:34,代码来源:text_summary.py

示例12: testPluginAssetSerialized

  def testPluginAssetSerialized(self):
    with ops.Graph().as_default() as g:
      plugin_asset.get_plugin_asset(ExamplePluginAsset)

      logdir = self.get_temp_dir()
      fw = writer.FileWriter(logdir)
      fw.add_graph(g)
    plugin_dir = os.path.join(logdir, writer._PLUGINS_DIR, "example")

    with gfile.Open(os.path.join(plugin_dir, "foo.txt"), "r") as f:
      content = f.read()
    self.assertEqual(content, "foo!")

    with gfile.Open(os.path.join(plugin_dir, "bar.txt"), "r") as f:
      content = f.read()
    self.assertEqual(content, "bar!")
开发者ID:brainwy12,项目名称:tensorflow,代码行数:16,代码来源:writer_test.py

示例13: testAddEmbeddingWithSpriteImageButNoThumbnailDim

  def testAddEmbeddingWithSpriteImageButNoThumbnailDim(self):
    manager = plugin_asset.get_plugin_asset(
        projector_plugin.ProjectorPluginAsset)

    thumbnails = np.array([[[1, 2, 3], [4, 5, 6], [7, 8, 9]]])
    with self.assertRaises(ValueError):
      manager.add_embedding(
          'test', np.array([[1], [2], [3]]), thumbnails=thumbnails)
开发者ID:LugarkPirog,项目名称:tensorflow,代码行数:8,代码来源:projector_plugin_test.py

示例14: testAddEmbeddingThumbnailDimNotOfLength2

  def testAddEmbeddingThumbnailDimNotOfLength2(self):
    manager = plugin_asset.get_plugin_asset(
        projector_plugin.ProjectorPluginAsset)

    thumbnails = np.array([[[1, 2, 3], [4, 5, 6], [7, 8, 9]]])
    with self.assertRaises(ValueError):
      manager.add_embedding(
          'test', np.array([[1], [2], [3]]), thumbnails=thumbnails,
          thumbnail_dim=[4])
开发者ID:LugarkPirog,项目名称:tensorflow,代码行数:9,代码来源:projector_plugin_test.py

示例15: testAddEmbeddingWithMetadataOfIncorrectLength

  def testAddEmbeddingWithMetadataOfIncorrectLength(self):
    manager = plugin_asset.get_plugin_asset(
        projector_plugin.ProjectorPluginAsset)

    metadata = projector_plugin.EmbeddingMetadata(3)
    metadata.add_column('labels', ['a', 'b', 'c'])
    # values has length 2, while metadata has length 3.
    values = np.array([[1], [2]])

    with self.assertRaises(ValueError):
      manager.add_embedding('test', values, metadata)
开发者ID:LugarkPirog,项目名称:tensorflow,代码行数:11,代码来源:projector_plugin_test.py


注:本文中的tensorflow.python.summary.plugin_asset.get_plugin_asset函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。