我有一个张量,我想打印调试
tensorflow::Tensor image_tensor;
我试过
std::cout << &image_tensor;
但我得到这样的东西:
0x16fd81cf8I
答案 0 :(得分:3)
你必须使用.vec或.flat方法。
让我们说张量是int8
// for i in image_tensor.size …
cout << i << “ “ << image_tensor.vec<int8>()(i)
另请参阅此答案How to fill a tensor in C++
答案 1 :(得分:-2)
使用// script.js
$(document).ready(function () {
var value = Math.random;
if (value <= 0.1) {
$("#top-left").html("<img src='file.png'>");
} else if (value <= 0.2 && value > 0.1) {
$("#top-middle").html("<img src='file.png'>");
} else if (value <= 0.3 && value > 0.2) {
$("#top-right").html("<img src='file.png'>");
} else if (value <= 0.4 && value > 0.3) {
$("#middle-left").html("<img src='file.png'>");
} else if (value <= 0.5 && value > 0.4) {
$("#middle-middle").html("<img src='file.png'>");
} else if (value <= 0.6 && value > 0.5) {
$("#middle-right").html("<img src='file.png'>");
} else if (value <= 0.7 && value > 0.6) {
$("#bottom-left").html("<img src='file.png'>");
} else if (value <= 0.8 && value > 0.7) {
$("#bottom-middle").html("<img src='file.png'>");
} else {
$("#bottom-right").html("<img src='file.png'>");
}
});
<!-- page.html -->
<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script>
<script type="text/javascript" src="script.js"></script>
</head>
<body>
<table border="1px">
<tr>
<td class="square" id="top-left"></td>
<td class="square" id="top-middle"></td>
<td class="square" id="top-right"></td>
</tr>
<tr>
<td class="square" id="middle-left"></td>
<td class="square" id="middle-middle"></td>
<td class="square" id="middle-right"></td>
</tr>
<tr>
<td class="square" id="bottom-left"></td>
<td class="square" id="bottom-middle"></td>
<td class="square" id="bottom-right"></td>
</tr>
</table>
</body>
</html>
,您要求打印张量的地址 - 以及您得到的内容。
尝试std::cout << &image_tensor;
(不&amp;)