aboutsummaryrefslogtreecommitdiffhomepage
path: root/tensorflow/tensorboard/app/tf-tensorboard-demo.html
blob: 5f0ef5b00c76bfd7dc84a1b7b7ef2f75b3bc7177 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
<link rel="import" href="../bower_components/polymer/polymer.html">
<link rel="import" href="tf-tensorboard.html">
<!--
tf-tensorboard-demo creates a demo instance of TensorBoard.

It expects to load data from a folder called tensorboard/

The way it ensures the urls are correct is quite hacky.
TODO(danmane): Fix the url handling during cleanup.
-->
<dom-module id="tf-tensorboard-demo">
  <template>
    <template is="dom-if" if="[[_urlsReady]]">
      <tf-tensorboard mode="[[mode]]"></tf-tensorboard>
    </template>
    <template is="dom-if" if="[[!_urlsReady]]">
      <p>
        urls not ready - probably because a dataDir was not provided
      </p>
    </template>
    <style>
    :host {
      display: block;
      width: 100%;
      height: 100%;
      }
    </style>
  </template>
  <script>
    Polymer({
      is: "tf-tensorboard-demo",
      properties: {
        mode: {
          type: String,
          value: "events",
        },
        dataDir: {
          type: String,
        },
        _urlsReady: {
          type: Boolean,
          value: false,
        },
      },
      observers: ['_setupUrls(dataDir)'],
      _setupUrls: function(dataDir) {
        function router(route) {
          return function(tag, run) {
            run = run.replace(/[ \)\(]/g, "_");
            tag = tag.replace(/[ \)\(]/g, "_");
            return dataDir + "/" + route + "/" + run + "/" + tag + ".json";
          };
        }
        TF.Urls.runsUrl = function() {
          return dataDir + "/runs.json"
        };
        TF.Urls.graphUrl = function(run) {
          run = run.replace(/ /g, "_");
          return dataDir + "/graph/" + run + ".pbtxt";
        };
        TF.Urls.scalarsUrl = router("scalars");
        TF.Urls.histogramsUrl = router("histograms");
        TF.Urls.compressedHistogramsUrl = router("compressedHistograms");
        TF.Urls.imagesUrl = router("images");
        TF.Urls.individualImageUrl = function(query) {
          return dataDir + "/individualImage/" + query + ".png";
        }
        this._urlsReady = true;
      },
    });
  </script>
</dom-module>