Using the **TRAINS** [Logger](https://github.com/allegroai/trains/blob/master/trains/logger.py) module and other **TRAINS** features, you can explicitly log any of the following:
* Report graphs and images
* [Scalar metrics](#scalar-metrics)
* [Histograms](#histograms)
* [Line plots](#line-plots)
* [2D scatter diagrams](#2d-scatter-diagrams)
* [3D scatter diagrams](#3d-scatter-diagrams)
* [Confusion matrices](#confusion-matrices)
* [Surface diagrams](#surface-diagrams)
* [Images](#images)
* Track hyper-parameters and OS environment variables
* Specifying [environment variables](#specifying-environment-variables-to-track) to track
* Message logging
* [Reporting text without formatting](#reporting-text-without-formatting)
Additionally, the **TRAINS** Logger module provides methods that allow you to do the following:
* Get the [current logger]()
* Overrride the TRAINS configuration file with a [default upload destination]() for images and files
## Graphs and Images
### Scalar Metrics
Use to report scalar metrics by iteration as a line plot.
First [get the current logger](#get-the-current-logger) and then use it (see an [example script](https://github.com/allegroai/trains/blob/master/examples/manual_reporting.py)) with the following method.
Use to report any data by iteration as a histogram.
First [get the current logger](#get-the-current-logger) and then use it (see an [example script](https://github.com/allegroai/trains/blob/master/examples/manual_reporting.py)) with the following method.
<td>Labels for each bar group in the histogram. The default value is <code>None</code>.
</td>
<td>No
</td>
</tr>
<tr>
<td>xlabels
</td>
<td>list of strings
</td>
<td>Labels for each bucket in the histogram. Each label in the <code>xlabels</code> list corresponds to a value in the <code>values</code> list (or numpy array). The default value is <code>None</code>.
</td>
<td>No
</td>
</tr>
</tbody>
</table>
### Line Plots
Use to report any data by iteration as a single or multiple line plot.
First [get the current logger](#get-the-current-logger) and then use it (see an [example script](https://github.com/allegroai/trains/blob/master/examples/manual_reporting.py)) with the following method.
<td>One (single line plot) or more (multiple line plot) series of data.
</td>
<td>Yes
</td>
</tr>
<tr>
<td>title
</td>
<td>string
</td>
<td>The plot title.
</td>
<td>Yes
</td>
</tr>
<tr>
<td>comment
</td>
<td>string
</td>
<td>Any text (e.g., subtitle or other comment) which displays under the plot title. The default value is <code>None</code>.
</td>
<td>No
</td>
</tr>
<tr>
<td>mode
</td>
<td>string
</td>
<td>Type of line plot. The values are:
<ul>
<li><code>lines</code> - lines connecting data points (default)
</li>
<li><code>markers</code> - markers for each data point
</li>
<li><code>lines+markers</code> - lines and markers
</li>
</ul>
</td>
<td>No
</td>
</tr>
<tr>
<td>reverse_xaxis
</td>
<td>boolean
</td>
<td>Indicates whether to display the x-axis values in ascending or descending order. The values are:
<ul>
<li><code>True</code> - descending order
</li>
<li><code>False</code> - ascending order (default)
</li>
</ul>
</td>
<td>No
</td>
</tr>
<tr>
<td>xaxis
</td>
<td>string
</td>
<td>x-axis title.
</td>
<td>No
</td>
</tr>
<tr>
<td>yaxis
</td>
<td>string
</td>
<td>y-axis title.
</td>
<td>No
</td>
</tr>
</tbody>
</table>
### 2D Scatter Diagrams
Use to report any vector data as a 2D scatter diagram.
First [get the current logger](#get-the-current-logger) and then use it (see an [example script](https://github.com/allegroai/trains/blob/master/examples/manual_reporting.py)) with the following method.
<td>The scatter data. For example, a list of pairs in the form: <code>[(x1,y1),(x2,y2),(x3,y3),...]</code>.
</td>
<td>Yes
</td>
</tr>
<tr>
<td>series
</td>
<td>string
</td>
<td>The data series label.
</td>
<td>Yes
</td>
</tr>
<tr>
<td>title
</td>
<td>string
</td>
<td>The plot title.
</td>
<td>Yes
</td>
</tr>
<tr>
<td>comment
</td>
<td>string
</td>
<td>Any text (e.g., subtitle or other comment) which displays under the plot title. The default value is <code>None</code>.
</td>
<td>No
</td>
</tr>
<tr>
<td>labels
</td>
<td>list of strings
</td>
<td>Label text per data point in the scatter diagram. The default value is <code>None</code>.
</td>
<td>No
</td>
</tr>
<tr>
<td>mode
</td>
<td>string
</td>
<td>Type of 2D scatter diagram. The values are:
<ul>
<li><code>lines</code> - lines connecting data points (default)
</li>
<li><code>markers</code> - markers for each data point
</li>
<li><code>lines+markers</code> - lines and markers
</li>
</ul>
</td>
<td>No
</td>
</tr>
<tr>
<td>xaxis
</td>
<td>string
</td>
<td>x-axis title. The default value is <code>None</code>.
</td>
<td>No
</td>
</tr>
<tr>
<td>yaxis
</td>
<td>string
</td>
<td>y-axis title. The default value is <code>None</code>.
</td>
<td>No
</td>
</tr>
</tbody>
</table>
### 3D Scatter Diagrams
Use to report any array data as a 3D scatter diagram.
First [get the current logger](#get-the-current-logger) and then use it (see an [example script](https://github.com/allegroai/trains/blob/master/examples/manual_reporting.py)) with the following method.
<td>Any text (e.g., subtitle or other comment) which displays under the plot title. The default value is <code>None</code>.
</td>
<td>No
</td>
</tr>
<tr>
<td>fill
</td>
<td>boolean
</td>
<td>Indicates whether to fill the area under the scatter diagram. The values are:
<ul>
<li><code>True</code> - fill
</li>
<li><code>False</code> - do not fill (default)
</li>
</ul>
</td>
<td>No
</td>
</tr>
<tr>
<td>labels
</td>
<td>list of strings
</td>
<td>Label text per data point in the scatter. The default value is <code>None</code>.
</td>
<td>No
</td>
</tr>
<tr>
<td>mode
</td>
<td>string
</td>
<td>Type of 3D scatter diagram. The values are:
<ul>
<li><code>lines</code>
</li>
<li><code>markers</code>
</li>
<li><code>lines+markers</code>
</li>
</ul>
The default values is <code>lines</code>.
</td>
<td>No
</td>
</tr>
</tbody>
</table>
### Confusion Matrices
Use to report a heat-map matrix as a confusion matrix. You can also plot a heat-map as a [surface diagram](#surface-diagrams).
First [get the current logger](#get-the-current-logger) and then use it (see an [example script](https://github.com/allegroai/trains/blob/master/examples/manual_reporting.py)) with the following method.
<td>Label per column of the matrix. The default value is <code>None</code>.
</td>
<td>No
</td>
</tr>
<tr>
<td>ylabels
</td>
<td>list of strings
</td>
<td>Label per row of the matrix. The default value is <code>None</code>.
</td>
<td>No
</td>
</tr>
</tbody>
</table>
### Surface Diagrams
Use to plot a heat-map matrix as a surface diagram. You can also plot a heat-map as a [confusion matrix](#confusion-matrices).
First [get the current logger](#get-the-current-logger) and then use it (see an [example script](https://github.com/allegroai/trains/blob/master/examples/manual_reporting.py)) with the following method.
Use to report an image and upload its contents to the bucket specified in the **TRAINS** configuration file,
or a [a default upload destination](#set-default-upload-destination), if you set a default.
First [get the current logger](#get-the-current-logger) and then use it (see an [example script](https://github.com/allegroai/trains/blob/master/examples/manual_reporting.py)) with the following method.
<td>Indicates whether to delete the local copy of the file after uploading it. The values are:
<ul>
<li><code>True</code> - delete
</li>
<li><code>False</code> - do not delete (default)
</li>
</ul>
</td>
<td>No
</td>
</tr>
<tr>
<td>matrix
</td>
<td>ndarray
</td>
<td>A 3D numpy.ndarray object containing image data (RGB). If <code>path</code> is not specified, then <code>matrix</code> is required. The default values is <code>None</code>.
</td>
<td>No
</td>
</tr>
<tr>
<td>max_image_history
</td>
<td>integer
</td>
<td>The maximum number of images to store per metric / variant combination. For an unlimited number of images to store, specify a negative number.
The default value which is set in the global configuration is <code>5</code>.
<td>The path of the image file. If <code>matrix</code> is not specified, then <code>path</code> is required. The default values is <code>None</code>.
</td>
<td>No
</td>
</tr>
</tbody>
</table>
## Hyper-parameters and Environment Variables
### Logging Experiment Parameter Dictionaries
In order for **TRAINS** to log a dictionary of parameters, use the `Task.connect` method.
For example, to log the hyper-parameters <code>learning_rate</code>, <code>batch_size</code>, <code>display_step</code>, <code>model_path</code>, <code>n_hidden_1</code>, and <code>n_hidden_2</code>:
By setting the `TRAINS_LOG_ENVIRONMENT` environment variable, make **TRAINS** log either:
* All environment variables
export TRAINS_LOG_ENVIRONMENT="*"
* Specific environment variables
For example, log `PWD` and `PYTHONPATH`
export TRAINS_LOG_ENVIRONMENT="PWD,PYTHONPATH"
* No environment variables
export TRAINS_LOG_ENVIRONMENT=
## Logging Messages
Use the methods in this section to log various types of messages. The method name describes the type of message.
### Debugging Messages
**Method**:
```python
def debug(self, msg, *args, **kwargs)
```
First [get the current logger](#get-the-current-logger) and then use it (see an [example script](https://github.com/allegroai/trains/blob/master/examples/manual_reporting.py)) with the following method.
**Arguments**:
<tablewidth="100%">
<thead>
<tr>
<thwidth="15%">Parameter
</th>
<thwidth="25%">Type
</th>
<thwidth="55%">Description
</th>
<thwidth="5%">Mandatory
</th>
</tr>
</thead>
<tr>
<td>msg
</td>
<td>string
</td>
<td>The text to log.
</td>
<td>Yes
</td>
</tr>
</tbody>
</table>
### Informational Messages
**Method**:
```python
def info(self, msg, *args, **kwargs)
```
First [get the current logger](#get-the-current-logger) and then use it (see an [example script](https://github.com/allegroai/trains/blob/master/examples/manual_reporting.py)) with the following method.
**Arguments**:
<tablewidth="100%">
<thead>
<tr>
<thwidth="15%">Parameter
</th>
<thwidth="25%">Type
</th>
<thwidth="55%">Description
</th>
<thwidth="5%">Mandatory
</th>
</tr>
</thead>
<tr>
<td>msg
</td>
<td>string
</td>
<td>The text to log.
</td>
<td>Yes
</td>
</tr>
</tbody>
</table>
### Warnings
**Method**:
```python
def warn(self, msg, *args, **kwargs)
```
First [get the current logger](#get-the-current-logger) and then use it (see an [example script](https://github.com/allegroai/trains/blob/master/examples/manual_reporting.py)) with the following method.
**Arguments**:<aname="log_arguments"></a>
<tablewidth="100%">
<thead>
<tr>
<thwidth="15%">Parameter
</th>
<thwidth="25%">Type
</th>
<thwidth="55%">Description
</th>
<thwidth="5%">Mandatory
</th>
</tr>
</thead>
<tbody>
<tr>
<td>msg
</td>
<td>string
</td>
<td>The text to log.
</td>
<td>Yes
</td>
</tr>
</tbody>
</table>
### General Errors
**Method**:
```python
def error(self, msg, *args, **kwargs)
```
First [get the current logger](#get-the-current-logger) and then use it (see an [example script](https://github.com/allegroai/trains/blob/master/examples/manual_reporting.py)) with the following method.
**Arguments**:
<tablewidth="100%">
<thead>
<tr>
<thwidth="15%">Parameter
</th>
<thwidth="25%">Type
</th>
<thwidth="55%">Description
</th>
<thwidth="5%">Mandatory
</th>
</tr>
</thead>
<tr>
<td>msg
</td>
<td>string
</td>
<td>The text to log.
</td>
<td>Yes
</td>
</tr>
</tbody>
</table>
### Critical Errors
**Method**:
```python
def critical(self, msg, *args, **kwargs)
```
First [get the current logger](#get-the-current-logger) and then use it (see an [example script](https://github.com/allegroai/trains/blob/master/examples/manual_reporting.py)) with the following method.
**Arguments**:
<tablewidth="100%">
<thead>
<tr>
<thwidth="15%">Parameter
</th>
<thwidth="25%">Type
</th>
<thwidth="55%">Description
</th>
<thwidth="5%">Mandatory
</th>
</tr>
</thead>
<tr>
<td>msg
</td>
<td>string
</td>
<td>The text to log.
</td>
<td>Yes
</td>
</tr>
</tbody>
</table>
### Fatal Errors
**Method**:
```python
def fatal(self, msg, *args, **kwargs)
```
First [get the current logger](#get-the-current-logger) and then use it (see an [example script](https://github.com/allegroai/trains/blob/master/examples/manual_reporting.py)) with the following method.
First [get the current logger](#get-the-current-logger) and then use it (see an [example script](https://github.com/allegroai/trains/blob/master/examples/manual_reporting.py)) with the following method.
**Arguments**:
<tablewidth="100%">
<thead>
<tr>
<thwidth="15%">Parameter
</th>
<thwidth="25%">Type
</th>
<thwidth="55%">Description
</th>
<thwidth="5%">Mandatory
</th>
</tr>
</thead>
<tr>
<td>msg
</td>
<td>string
</td>
<td>The text to log.
</td>
<td>Yes
</td>
</tr>
<tr>
<td>level
</td>
<td>string
</td>
<td>The log level. The values are:
<ul>
<li><code>logging.DEBUG</code>
</li>
<li><code>logging.INFO</code>
</li>
<li><code>logging.WARNING</code>
</li>
<li><code>logging.ERROR</code>
</li>
<li><code>logging.FATAL</code>
</li>
<li><code>logging.CRITICAL</code>
</li>
</ul>
</td>
<td>No
</td>
</tr>
<tr>
<td>omit_console
</td>
<td>boolean
</td>
<td>Indicates whether to send the message to the log only. The values are:
<ul>
<li><code>True</code> - send the message to the log only
</li>
<li><code>False</code> - send the message to the console and the log
First [get the current logger](#get-the-current-logger) and then use it (see an [example script](https://github.com/allegroai/trains/blob/master/examples/manual_reporting.py)) with the following method.
**Arguments**:
<tablewidth="100%">
<thead>
<tr>
<thwidth="15%">Parameter
</th>
<thwidth="25%">Type
</th>
<thwidth="55%">Description
</th>
<thwidth="5%">Mandatory
</th>
</tr>
</thead>
<tbody>
<tr>
<td>msg
</td>
<td>string
</td>
<td>The text to log.
</td>
<td>Yes
</td>
</tr>
<tr>
<td>level
</td>
<td>string
</td>
<td>The log level. The values are:
<ul>
<li><code>logging.DEBUG</code>
</li>
<li><code>logging.INFO</code>
</li>
<li><code>logging.WARNING</code>
</li>
<li><code>logging.ERROR</code>
</li>
<li><code>logging.FATAL</code>
</li>
<li><code>logging.CRITICAL</code>
</li>
</ul>
</td>
<td>No
</td>
</tr>
<tr>
<td>print_console
</td>
<td>boolean
</td>
<td>Indicates whether to log to the console, in addition to the log. The values are:
<ul>
<li><code>True</code> - print to the console and log
</li>
<li><code>False</code> - print to the log, only (default)
</li>
</ul>
</td>
<td>No
</td>
</tr>
</tbody>
</table>
## Logger Object and Storage Methods
### Get the Current Logger
Use to return a reference to the current logger object.
**Method**:
```python
def current_logger(cls)
```
**Arguments**:
None.
### Set Default Upload Destination
Use to specify the default destination storage location used for uploading images.
Images are uploaded and a link to the image is reported.
Credentials for the storage location are in the global configuration file (for example, on Linux, <code>~/trains.conf</code>).
**Method**:
```python
def set_default_upload_destination(self, uri)
```
**Arguments**:
<tablewidth="100%">
<thead>
<tr>
<thwidth="15%">Parameter
</th>
<thwidth="25%">Type
</th>
<thwidth="55%">Description
</th>
<thwidth="5%">Mandatory
</th>
</tr>
</thead>
<tbody>
<tr>
<td>uri
</td>
<td>string
</td>
<td>The destination storage location, for example <code>s3://bucket/directory/</code> or <code>file:///tmp/debug/</code>.