digideep.utility package¶
Subpackages¶
Submodules¶
digideep.utility.filter module¶
-
class
digideep.utility.filter.
MovingAverage
(size=1, window_size=10)[source]¶ Bases:
object
An implementation of moving average. It has an internal queue of the values.
Parameters: - size (python:int) – The length of the value vector.
- window_size (python:int) – The window size for calculation of the moving average.
-
data
¶
-
max
¶
-
mean
¶
-
median
¶
-
min
¶
-
std
¶
digideep.utility.logging module¶
-
class
digideep.utility.logging.
Logger
[source]¶ Bases:
object
This is a helper class which is intended to simplify logging in a single file from different modules in a package. The
Logger
class uses a singleton [1] pattern.It also provides multi-level logging each in a specific style. The levels are
DEBUG
,INFO
,WARN
,ERROR
,FATAL
.logger.set_log_level(2) logger.info('This is a test of type INFO.') # Will not be shown logger.warn('This is a test of type WARN.') # Will be shown logger.fatal('This is a test of type FATAL.') # Will be shown logger.set_log_level(3) logger.info('This is a test of type INFO.') # Will not be shown logger.warn('This is a test of type WARN.') # Will not be shown logger.fatal('This is a test of type FATAL.') # Will be shown logger.set_logfile('path_to_the_log_file') # ... All logs will be stored in the specified file from now on. # They will be shown on the output as well.
Footnotes
[1] https://gist.github.com/pazdera/1098129
digideep.utility.monitoring module¶
-
class
digideep.utility.monitoring.
Monitor
[source]¶ Bases:
object
A very simple and lightweight implementation for a global monitoring tool. This class keeps track of a variable’s mean, standard deviation, minimum, maximum, and sum in a recursive manner.
>>> monitor.reset() >>> for i in range(1000): ... monitor('loop index', i) ... >>> print(monitor) >> loop index [1000x] = 499.5 (+-577.639 %95) in range{0 < 999}
Todo
Provide batched monitoring of variables.
Note
This class does not implement moving average. For a moving average implementation refer to
MovingAverage
.
digideep.utility.plotting module¶
digideep.utility.profiling module¶
-
class
digideep.utility.profiling.
Profiler
[source]¶ Bases:
object
This class provides a very simple yet light implementation of function profiling. It is very easy to use:
>>> profiler.reset() >>> profiler.start("loop") >>> for i in range(100000): ... print(i) ... >>> profiler.lapse("loop") >>> print(profiler) >> loop [1x, 27.1s]
Alternatively, you may use
profiler
withKeepTime
:>>> with KeepTime("loop2"): ... for i in range(100000): ... print(i) ... >>> print(profiler) >> loop2 [1x, 0.0s]
digideep.utility.stats module¶
digideep.utility.timer module¶
-
class
digideep.utility.timer.
Timer
(task, interval=1.0)[source]¶ Bases:
threading.Thread
Thread that executes a task every N seconds
-
run
()[source]¶ Method representing the thread’s activity.
You may override this method in a subclass. The standard run() method invokes the callable object passed to the object’s constructor as the target argument, if any, with sequential and keyword arguments taken from the args and kwargs arguments, respectively.
-
digideep.utility.toolbox module¶
-
digideep.utility.toolbox.
count_parameters
(model)[source]¶ Counts the number of parameters in a PyTorch model.
-
digideep.utility.toolbox.
dump_dict_as_json
(filename, dic, sort_keys=False)[source]¶ This function dumps a python dictionary in
json
format to a file.Parameters:
-
digideep.utility.toolbox.
get_class
(addr)[source]¶ Return a instance of a class by using only its name.
Parameters: addr (str) – The name of the class/function which should be in the format MODULENAME[.SUBMODULE1[.SUBMODULE2[...]]].CLASSNAME