2016-06-28 22 views
8

Tôi hủy bỏ mã Tensorflow của mình bằng các nosetests nhưng nó tạo ra số lượng đầu ra tiết ra như vậy khiến nó vô dụng.Làm cách nào để ngăn chặn ghi nhật ký Tensorflow tiết kiệm?

Các thử nghiệm sau

import unittest 
import tensorflow as tf 

class MyTest(unittest.TestCase): 

    def test_creation(self): 
     self.assertEquals(True, False) 

khi chạy với nosetests tạo ra một số tiền rất lớn của khai thác gỗ vô dụng:

FAIL: test_creation (tests.test_tf.MyTest) 
---------------------------------------------------------------------- 
Traceback (most recent call last): 
    File "/home/cebrian/GIT/thesis-nilm/code/deepmodels/tests/test_tf.py", line 10, in test_creation 
    self.assertEquals(True, False) 
AssertionError: True != False 
-------------------- >> begin captured logging << -------------------- 
tensorflow: Level 1: Registering Const (<function _ConstantShape at 0x7f4379131c80>) in shape functions. 
tensorflow: Level 1: Registering Assert (<function no_outputs at 0x7f43791319b0>) in shape functions. 
tensorflow: Level 1: Registering Print (<function _PrintGrad at 0x7f4378effd70>) in gradient. 
tensorflow: Level 1: Registering Print (<function unchanged_shape at 0x7f4379131320>) in shape functions. 
tensorflow: Level 1: Registering HistogramAccumulatorSummary (None) in gradient. 
tensorflow: Level 1: Registering HistogramSummary (None) in gradient. 
tensorflow: Level 1: Registering ImageSummary (None) in gradient. 
tensorflow: Level 1: Registering AudioSummary (None) in gradient. 
tensorflow: Level 1: Registering MergeSummary (None) in gradient. 
tensorflow: Level 1: Registering ScalarSummary (None) in gradient. 
tensorflow: Level 1: Registering ScalarSummary (<function _ScalarShape at 0x7f4378f042a8>) in shape functions. 
tensorflow: Level 1: Registering MergeSummary (<function _ScalarShape at 0x7f4378f042a8>) in shape functions. 
tensorflow: Level 1: Registering AudioSummary (<function _ScalarShape at 0x7f4378f042a8>) in shape functions. 
tensorflow: Level 1: Registering ImageSummary (<function _ScalarShape at 0x7f4378f042a8>) in shape functions. 
tensorflow: Level 1: Registering HistogramSummary (<function _ScalarShape at 0x7f4378f042a8>) in shape functions. 
tensorflow: Level 1: Registering HistogramAccumulatorSummary (<function _ScalarShape at 0x7f4378f042a8>) in shape functions. 
tensorflow: Level 1: Registering Pack (<function _PackShape at 0x7f4378f047d0>) in shape functions. 
tensorflow: Level 1: Registering Unpack (<function _UnpackShape at 0x7f4378f048c0>) in shape functions. 
tensorflow: Level 1: Registering Concat (<function _ConcatShape at 0x7f4378f04938>) in shape functions. 
tensorflow: Level 1: Registering ConcatOffset (<function _ConcatOffsetShape at 0x7f4378f049b0>) in shape functions. 

...... 

trong khi sử dụng tensorflow từ ipython console không có vẻ rằng verbose:

$ ipython 
Python 2.7.11+ (default, Apr 17 2016, 14:00:29) 
Type "copyright", "credits" or "license" for more information. 

IPython 4.2.0 -- An enhanced Interactive Python. 
?   -> Introduction and overview of IPython's features. 
%quickref -> Quick reference. 
help  -> Python's own help system. 
object? -> Details about 'object', use 'object??' for extra details. 

In [1]: import tensorflow as tf 
I tensorflow/stream_executor/dso_loader.cc:108] successfully opened CUDA library libcublas.so locally 
I tensorflow/stream_executor/dso_loader.cc:108] successfully opened CUDA library libcudnn.so locally 
I tensorflow/stream_executor/dso_loader.cc:108] successfully opened CUDA library libcufft.so locally 
I tensorflow/stream_executor/dso_loader.cc:108] successfully opened CUDA library libcuda.so locally 
I tensorflow/stream_executor/dso_loader.cc:108] successfully opened CUDA library libcurand.so locally 

In [2]: 

Làm cách nào tôi có thể chặn nhật ký cũ khi chạy nosetests?

+0

có thể trùng lặp của [Disable Tensorflow thông tin gỡ lỗi] (http://stackoverflow.com/questions/35911252/disable-tensorflow-debugging-information) – craymichael

+0

Một giải pháp khác: https: //stackoverflow.com/questions/43337601/nosetests-with-tensorflow-lots-of-debugging-output-how-to-disable – vpekar

Trả lời

0

Đây là an example để thực hiện việc này. Thật không may điều này đòi hỏi phải sửa đổi nguồn và xây dựng lại. Dưới đây là một tracking bug để làm cho nó dễ dàng hơn

18

1.0 Cập nhật (5/20/17):

Trong TensorFlow 1.0, mỗi issue này, bạn có thể bây giờ kiểm soát khai thác gỗ thông qua biến môi trường được gọi là TF_CPP_MIN_LOG_LEVEL; nó mặc định là 0 (tất cả nhật ký được hiển thị), nhưng có thể được đặt thành 1 để lọc ra các nhật ký INFO, 2 để lọc thêm WARNING nhật ký và 3 để lọc thêm ERROR nhật ký. Xem generic dụ OS sau sử dụng Python:

import os 
import tensorflow as tf 

os.environ['TF_CPP_MIN_LOG_LEVEL'] = '3' 

Đối với các phiên bản trước của TensorFlow hoặc TF-Tìm hiểu Logging, thấy như sau:

Xem trang dưới đây để biết thông tin về TensorFlow khai thác gỗ; với bản cập nhật mới, bạn có thể đặt độ dài ghi nhật ký thành DEBUG, INFO, WARN, ERROR hoặc FATAL. Ví dụ:

tf.logging.set_verbosity(tf.logging.ERROR) 

Trang này cũng có thể được sử dụng với các mô hình TF-Learn. Here is the page.

không chặn tất cả ghi nhật ký, mặc dù (chỉ TF-Learn). Tôi có hai giải pháp; một là một giải pháp 'kỹ thuật chính xác' (Linux) và cái kia liên quan đến việc xây dựng lại TensorFlow.

script -c 'python [FILENAME].py' | grep -v 'I tensorflow/' 

Mặt khác, vui lòng xem this answer liên quan đến sửa đổi nguồn và xây dựng lại TensorFlow.

Các vấn đề liên quan