# I/O Layers

The I/O components of the core engine implement the mechanism needed to make possible the connection of a neural network to external sources of data, either to read the patterns to elaborate, or to store of the results of the network to whatever output device is required.

All the I/O components extend the Synapse object, so they can be ‘attached’ to the input or the output of a generic Layer object since they expose the same interface required by any i/o listener of a Layer.

Using this simple mechanism the Layer is not affected by the kind of synapse connected to it because as they all have the same interface, the Layer will continue to call the Get and Put methods without needing to know more about their specialization.

## The Input mechanism

To permit the user to utilize any source of data as input of a neural network, a complete input mechanism has been designed into the core engine.

The main concept underlying the input system is that a neural network elaborates ‘patterns’. A pattern is composed by a row of values [x11, x12, …, x1N] representing an instance of the input dataset.

The neural network reads and elaborates sequentially all the input rows (all constituted by the same number of values – or columns) and for each one it generates an output pattern representing the outcome of the entire process.

We need two main features to reach the goal to make this mechanism as more as flexible we can:

Firstly, to represent a row of values Joone uses an array of double, hence to permit to use whatever format of data from whatever source, we need a ‘format converter’. It’s based on the concept that a neural network can elaborate only numerical data (integer or real), hence a system to convert any external format to numeric values is provided. This acts as a ‘pluggable’ driver: with Joone is provided an interface and some basic drivers (for instance one to read ASCII values and another to read Excel sheets) to convert the input values to an array of double - the unique format accepted by a neural network to work properly.

This mechanism is expansible, as everyone can write new drivers implementing the provided interfaces.

Secondly, because normally not all the available rows and columns have to be used as input data, a ‘selection mechanism’ to select the input values is provided. This second feature is implemented as a component interposed between the above driver and the first layer of the neural network.

The 'cut' of the needed input columns is made by using a paremeter named AdvancedColumnSelector.

The advanced column selector specifies what columns from the input source should be presented the next layer. For example if a file input contains 5 columns, you could specify that only columns 1 and 3 be presented to the next layer. The selector must be a list of one or a comma delimeted list of multiple options. The options can be one column '2' or a range of columns '3-6'. The format for the selector is as follows ...
[col]{,[col]{,[col1-col2]}}
For example if the input source has 5 columns and you would like to use column 1 and columns 3,4 and 5, you could specify the selector as '1,3-5' or '1,3,4,5'.

For specific needs the same column can be read many times within the same pattern, simply specifying the same number more than once, like in the following example: '1,3,3,3,4'.

## The Output components

The Output components allow a neural network to write output patterns to a whatever storing support.

They write all the values of the pattern passed by the calling attached Layer to an output stream, permitting the output patterns from an interrogation phase to be written as, for example, ASCII files, FTP sites, spreadsheets, charting visual components, etc.

Joone has several real implementations of the output classes to write patterns in the following formats:

- Comma separated ASCII values
- Excel spreadsheets
- RDBMS tables using JDBC
- Java Arrays - to write the output in a 2D array of doubles, to use the output of a neural network from an embedding or external application.