2017-12-14 123 views

उत्तर

1

यहां बताया गया है कि आप Google कोलाब पर अपने मॉडल इनलाइन कैसे प्रदर्शित कर सकते हैं।

from IPython.display import clear_output, Image, display, HTML 
import tensorflow as tf 
import numpy as np 
from google.colab import files 

def strip_consts(graph_def, max_const_size=32): 
    """Strip large constant values from graph_def.""" 
    strip_def = tf.GraphDef() 
    for n0 in graph_def.node: 
     n = strip_def.node.add() 
     n.MergeFrom(n0) 
     if n.op == 'Const': 
      tensor = n.attr['value'].tensor 
      size = len(tensor.tensor_content) 
      if size > max_const_size: 
       tensor.tensor_content = "<stripped %d bytes>"%size 
    return strip_def 

def show_graph(graph_def, max_const_size=32): 
    """Visualize TensorFlow graph.""" 
    if hasattr(graph_def, 'as_graph_def'): 
     graph_def = graph_def.as_graph_def() 
    strip_def = strip_consts(graph_def, max_const_size=max_const_size) 
    code = """ 
     <script> 
      function load() {{ 
      document.getElementById("{id}").pbtxt = {data}; 
      }} 
     </script> 
     <link rel="import" href="https://tensorboard.appspot.com/tf-graph-basic.build.html" onload=load()> 
     <div style="height:600px"> 
      <tf-graph-basic id="{id}"></tf-graph-basic> 
     </div> 
    """.format(data=repr(str(strip_def)), id='graph'+str(np.random.rand())) 

    iframe = """ 
     <iframe seamless style="width:1200px;height:620px;border:0" srcdoc="{}"></iframe> 
    """.format(code.replace('"', '&quot;')) 
    display(HTML(iframe)) 


"""Create a sample tensor""" 
sample_placeholder= tf.placeholder(dtype=tf.float32) 
"""Show it""" 
graph_def = tf.get_default_graph().as_graph_def() 
show_graph(graph_def) 

वर्तमान में, आप गूगल Colab पर एक Tensorboard सेवा जिस तरह से आप यह स्थानीय स्तर पर नहीं चला चला सकते हैं: नीचे एक बहुत ही सरल उदाहरण है कि एक प्लेसहोल्डर प्रदर्शित करता है। साथ ही, आप summary_writer = tf.summary.FileWriter('./logs', graph_def=sess.graph_def) जैसे कुछ के माध्यम से अपने पूरे लॉग को अपने ड्राइव पर निर्यात नहीं कर सकते हैं ताकि आप इसे डाउनलोड कर सकें और इसे स्थानीय रूप से देख सकें।

9

मैं वर्तमान में स्थानीयहोस्ट पर सुरंग यातायात के लिए ngrok का उपयोग करता हूं।
एक कोलाब उदाहरण here पाया जा सकता है।

  1. प्राप्त TensorBoard पृष्ठभूमि में चल रहा:

    ये कदम (कोड के टुकड़े प्रकार "कोड" colab में की कोशिकाओं का प्रतिनिधित्व करते हैं) कर रहे हैं।
    this answer से प्रेरित हो गया।

    LOG_DIR = '/tmp/log' 
    get_ipython().system_raw(
        'tensorboard --logdir {} --host 0.0.0.0 --port 6006 &' 
        .format(LOG_DIR) 
    ) 
    
  2. डाउनलोड करें और ngrok अनज़िप।
    लिंक को अपने ओएस के लिए सही डाउनलोड लिंक के साथ wget पर बदलें।

    ! wget https://bin.equinox.io/c/4VmDzA7iaHb/ngrok-stable-linux-amd64.zip 
    ! unzip ngrok-stable-linux-amd64.zip 
    
  3. लॉन्च ngrok पृष्ठभूमि प्रक्रिया ...

    get_ipython().system_raw('./ngrok http 6006 &') 
    

    ... और जनता के url प्राप्त। Source

    ! curl -s http://localhost:4040/api/tunnels | python3 -c \ 
        "import sys, json; print(json.load(sys.stdin)['tunnels'][0]['public_url'])" 
    
संबंधित मुद्दे