我无法得到DNNClassifier在训练时打印进度,即丢失和验证分数。据我所知,可以使用继承自BaseEstimator的config参数打印丢失,但是当我传递RunConfig对象时,分类器没有打印任何内容。
from tensorflow.contrib.learn.python.learn.estimators import run_config
config = run_config.RunConfig(verbose=1)
classifier = learn.DNNClassifier(hidden_units=[10, 20, 10],
n_classes=3,
config=config)
classifier.fit(X_train, y_train, steps=1000)
我错过了什么吗?我检查了RunConfig如何处理详细参数,看起来that it only cares if its greater than 1,它与文档不匹配:
详细:控制详细程度,可能的值: 0:算法和调试信息被静音。 1:培训师打印进度。 2:打印日志设备放置。
至于验证分数,我认为使用monitors.ValidationMonitor会很好,但是当尝试它时,分类器不会打印任何东西,尝试使用early_stopping_rounds时也没有任何反应。我在源代码中搜索文档或一些注释,但我找不到任何监视器。
答案 0 :(得分:14)
在fit函数之前添加这些以显示进度:
import logging
logging.getLogger().setLevel(logging.INFO)
样品:
INFO:tensorflow:global_step/sec: 0
INFO:tensorflow:Training steps [0,1000000)
INFO:tensorflow:Step 1: loss = 10.5043
INFO:tensorflow:training step 100, loss = 10.45380 (0.223 sec/batch).
INFO:tensorflow:Step 101: loss = 10.5623
INFO:tensorflow:training step 200, loss = 10.46701 (0.220 sec/batch).
INFO:tensorflow:Step 201: loss = 10.3885
INFO:tensorflow:training step 300, loss = 10.36501 (0.232 sec/batch).
INFO:tensorflow:Step 301: loss = 10.3441
INFO:tensorflow:training step 400, loss = 10.44571 (0.220 sec/batch).
INFO:tensorflow:Step 401: loss = 10.396
INFO:tensorflow:global_step/sec: 3.95
答案 1 :(得分:2)
在训练之前添加此行:
<table>
<?php
//database connent
include 'anslutsqli.php';
//sql select day from events have now two dates in my db
$sql = "SELECT day FROM test";
$result = mysqli_query($con, $sql);
//naming the sql dates var
$sqldates = array();
while($row=mysqli_fetch_array($result)){
array_push($sqldates, $row['day']);
}
//setting first day
$firstday = '1';
$two = cal_days_in_month(CAL_GREGORIAN, 8, 2018); // 31
//for loop to get all days in month( this makes the while loop run two times i have two dates in my db 3 and 4)
for ($number = $firstday; $number <= $two; $number++)
if (in_array($number, $sqldates)) {
echo"<td width=50 bgcolor='#f44242'>$sqldates</td>";
} else {
echo"<td width=50 bgcolor='#1e8e8e'>$number</td>";
}
?>
</table>