deephyp.data.Iterator

class deephyp.data.Iterator(dataSamples, targets, batchSize=None)[source]

Class for iterating through data, to train the network.

Parameters:
  • dataSamples (np.array float) – Data to be input into the network. Shape [numSamples x numBands].
  • targets (np.array int) – Network output target of each dataSample. For classification, these are the class labels, and it could be the dataSamples for autoencoders. Shape [numSamples x arbitrary]
  • batchSize (int) – Number of dataSamples per batch
dataSamples

Data to be input into the network. Shape [numSamples x numBands].

Type:np.array float
targets

Network output target of each dataSample. For classification, these are the class labels, and it could be the dataSamples for autoencoders. Shape [numSamples x arbitrary]

Type:np.array int
batchSize

Number of dataSamples per batch. If None - set to numSamples (i.e. whole dataset).

Type:int
numSamples

The number of data samples.

Type:int
currentBatch

A list of indexes specifying the data samples in the current batch. Shape [batchSize]

Type:int list
get_batch(idx)[source]

Returns a specified set of samples and targets.

Parameters:idx (int list) – Indexes of samples (and targets) to return.
Returns:2-element tuple containing:
  • (np.array float) - Batch of data samples at [idx] indexes. Shape [length(idx) x numBands].
  • (np.array int) - Batch of targets at [idx] indexes. Shape [length(idx) x arbitrary].
Return type:(tuple)
next_batch()[source]

Return next batch of samples and targets (with batchSize number of samples). The currentBatch indexes are incremented. If end of dataset reached, the indexes wraps around to the beginning.

Returns:2-element tuple containing:
  • (np.array float) - Batch of data samples at currentBatch indexes. Shape [batchSize x numBands].
  • (np.array int) - Batch of targets at currentBatch indexes. Shape [batchSize x arbitrary].
Return type:(tuple)
reset_batch()[source]

Resets the current batch to the beginning.

shuffle()[source]

Randomly permutes all dataSamples (and corresponding targets).