当前,我正在使用tf.Print
在估计器中打印(调试)张量,但是此api被标记为已弃用,建议我改用tf.print。根据{{3}},通过使用tf.print,我需要控制正在运行的会话,但是Estimator
旨在向用户隐藏会话和图形。那么,如何在Estimator中使用tf.print
?
答案 0 :(得分:0)
为了在图形模式下使用<script src="http://code.jquery.com/jquery-3.3.1.slim.min.js"></script>
<link href="http://stackpath.bootstrapcdn.com/bootstrap/4.1.0/css/bootstrap.min.css" rel="stylesheet"/>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.0/umd/popper.min.js"></script>
<script src="http://stackpath.bootstrapcdn.com/bootstrap/4.1.0/js/bootstrap.min.js"></script>
<link href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet"/>
<nav class="navbar navbar-expand-md bg-dark navbar-dark my-auto mx-0 p-0">
<a href="/" class="navbar-brand text-center app-logo">
<div class="d-lg-none d-sm-block"><strong>mAn</strong></div>
<div class="d-none d-lg-block d-sm-none">my App name</div>
</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#collapsingNavbar3">
<span class="navbar-toggler-icon"></span>
</button>
<div class="navbar-collapse collapse col-md-10 m-0 p-0" id="collapsingNavbar3">
<ul class="navbar-nav mr-auto">
<li class="nav-item active">
<a class="nav-link active" href="#">Home</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">About</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Contact</a>
</li>
</ul>
<ul class="nav navbar-nav right-nav">
<li class="nav-item ">
<a class="nav-link" href="#" id="displayName">UserName</a>
</li>
<li class="nav-item ">
<a id="btnBack" class="nav-link" style="" href="/logout">logout</a>
</li>
</ul>
</div>
</nav>
,tf.print
就是这样,您可以使用tf.estimator
来代替tf.print
,在执行model_fn中的张量之前强制执行tf.Print
操作,因此,给定model_fn的输入张量tf.print
,您可以:
input_
甚至
print_op = tf.print(tensor_to_log)
with tf.control_dependencies([print_op]):
first_layer_output = first_inpyt_layer(input_)