lrn2.data.domain package

Submodules

lrn2.data.domain.image module

class lrn2.data.domain.image.ImageBinaryVP(shape)[source]

Bases: lrn2.data.domain.viewpoint.ViewPoint

get_image_from_raw_data(data)[source]
raw_to_repr(raw_data, label)[source]
repr_to_visual(binary_data)[source]
shape
size

lrn2.data.domain.music module

class lrn2.data.domain.music.BeatInMeasureNaiveVP(n_batches=16)[source]

Bases: lrn2.data.domain.viewpoint.ViewPoint

get_onset_from_raw_data(data)[source]
raw_to_repr(raw_data, label)[source]
repr_to_visual(binary_data)[source]
size
class lrn2.data.domain.music.BoundaryStrengthVP(bs_file, min=10, max=50, n_batches=5, offset=0)[source]

Bases: lrn2.data.domain.viewpoint.ViewPoint

raw_to_repr(raw_data, label)[source]
repr_to_visual(binary_data)[source]
size
class lrn2.data.domain.music.DurationVP(min_dur=0, max_dur=4, n_batches=16)[source]

Bases: lrn2.data.domain.viewpoint.ViewPoint

get_duration_from_raw_data(data)[source]
raw_to_repr(raw_data, label)[source]
repr_to_visual(binary_data)[source]
size
class lrn2.data.domain.music.GammatoneVP(audiofile_sets, cache_dir=None, sample_rate=44100)[source]

Bases: lrn2.data.domain.viewpoint.ViewPoint

center_ngrams(ngrams, min_pitch, max_pitch)[source]

Transpose each n-gram by an integer multiple of an octave, to fit the pitch range to the n-gram between a minimum and maximum pitch.

Parameters:
  • ngrams (ndarray) – a 2D array of type int and size: len(pitches) x n, where each row contains an ngram of pitches
  • min_pitch (int) – minimal allowed pitch (inclusive)
  • max_pitch (int) – maximal allowed pitch (exclusive)
Returns:

ngrams – a 2D array of type int and size: len(pitches) x n, where each row contains an ngram of pitches, transposed by zero or more octaves to fit between min_pitch and max_pitch

Return type:

ndarray

extract_gammatone(audio_fn)[source]
get_pitch_from_raw_data(data)[source]
normalize(data)[source]
normalize2(data)[source]
note_names = array(['C', 'Db', 'D', 'Eb', 'E', 'F', 'Gb', 'G', 'Ab', 'A', 'Bb', 'B'], dtype='|S2')
note_names2 = ['C', 'Cs', 'D', 'Ds', 'E', 'F', 'Fs', 'G', 'Gs', 'A', 'As', 'B', 'c', 'cs', 'd', 'ds', 'e', 'f', 'fs', 'g', 'gs', 'a', 'as', 'b']
pitch_from_filename(fn)[source]

Extract the pitch symbol from a filename of the form “Piano.mf.Ab7.flac” and return the corresponding MIDI number.

pitch_from_label(fn)[source]

Extract the pitch symbol from a filename of the form “Piano.mf.Ab7.flac” and return the corresponding MIDI number.

raw_to_repr(raw_data, label)[source]

This viewpoint is now used to transform ngrams of representations created by other viewpoints, therefore the method is called ngram_to_binary rather than raw_to_binary. A bit ad-hoc, but it suits our needs for now.

pitch_ngrams is an M x N array containing M ngrams (size N) of integer MIDI pitch values

read_audio_audiolab(fn, mono=False)[source]

Get the signal from an audio file.

Parameters:
  • fn – filename of audio file
  • mono – if True, mix channels into a single channel
Returns:

A tuple (signal [nframes x nchannels], sample_freq)

repr_to_visual(binary_data)[source]
size
class lrn2.data.domain.music.GammatoneVPPoly(audiofile_sets, cache_dir=None, sample_rate=44100, quant_thresh=0.01)[source]

Bases: lrn2.data.domain.viewpoint.ViewPoint

center_ngrams(ngrams, min_pitch, max_pitch)[source]

Transpose each n-gram by an integer multiple of an octave, to fit the pitch range to the n-gram between a minimum and maximum pitch.

Parameters:
  • ngrams (ndarray) – a 2D array of type int and size: len(pitches) x n, where each row contains an ngram of pitches
  • min_pitch (int) – minimal allowed pitch (inclusive)
  • max_pitch (int) – maximal allowed pitch (exclusive)
Returns:

ngrams – a 2D array of type int and size: len(pitches) x n, where each row contains an ngram of pitches, transposed by zero or more octaves to fit between min_pitch and max_pitch

Return type:

ndarray

extract_gammatone(audio_fn)[source]
get_duration_from_raw_data(data)[source]
get_fn(pitch)[source]
get_onset_from_raw_data(data)[source]
get_pitch_from_raw_data(data)[source]
normalize(data)[source]
normalize2(data)[source]
note_names = array(['C', 'Db', 'D', 'Eb', 'E', 'F', 'Gb', 'G', 'Ab', 'A', 'Bb', 'B'], dtype='|S2')
note_names2 = ['C', 'Cs', 'D', 'Ds', 'E', 'F', 'Fs', 'G', 'Gs', 'A', 'As', 'B', 'c', 'cs', 'd', 'ds', 'e', 'f', 'fs', 'g', 'gs', 'a', 'as', 'b']
pitch_from_filename(fn)[source]

Extract the pitch symbol from a filename of the form “Piano.mf.Ab7.flac” and return the corresponding MIDI number.

pitch_from_label(fn)[source]

Extract the pitch symbol from a label (fn) of the form “fugue_1_D.mid” and return the corresponding MIDI number.

raw_to_repr(raw_data, label)[source]

This viewpoint is now used to transform ngrams of representations created by other viewpoints, therefore the method is called ngram_to_binary rather than raw_to_binary. A bit ad-hoc, but it suits our needs for now.

pitch_ngrams is an M x N array containing M ngrams (size N) of integer MIDI pitch values

read_audio_audiolab(fn, mono=False)[source]

Get the signal from an audio file.

Parameters:
  • fn – filename of audio file
  • mono – if True, mix channels into a single channel
Returns:

A tuple (signal [nframes x nchannels], sample_freq)

repr_to_visual(binary_data)[source]
size
to_gammatone(pitches)[source]
class lrn2.data.domain.music.HomophonicVP(quant_thresh=0.1, shuffle=False, pitch_class=False, min_sim_notes=1, min_dur_slice=0.0, add_harmonics=False, min_dur_note=0.0)[source]

Bases: lrn2.data.domain.viewpoint.ViewPoint

get_duration_from_raw_data(data)[source]
get_onset_from_raw_data(data)[source]
get_pitch_from_raw_data(data)[source]
harmonics = array([ 0, 12, 19, 24, 28, 31])
raw_to_repr(raw_data, label)[source]
repr_to_visual(binary_data)[source]
size
class lrn2.data.domain.music.IoiVP(min_ioi=0, max_ioi=4, n_batches=16)[source]

Bases: lrn2.data.domain.viewpoint.ViewPoint

get_onset_from_raw_data(data)[source]
raw_to_repr(raw_data, label)[source]
repr_to_visual(binary_data)[source]
size
class lrn2.data.domain.music.OctaveVP(max_pitch=127)[source]

Bases: lrn2.data.domain.viewpoint.ViewPoint

get_pitch_from_raw_data(data)[source]
raw_to_repr(raw_data, label)[source]
repr_to_visual(binary_data)[source]
size
class lrn2.data.domain.music.OoiVP(min_ooi=0, max_ooi=2, n_batches=4)[source]

Bases: lrn2.data.domain.viewpoint.ViewPoint

get_duration_from_raw_data(data)[source]
get_onset_from_raw_data(data)[source]
raw_to_repr(raw_data, label)[source]
repr_to_visual(binary_data)[source]
size
class lrn2.data.domain.music.PianoRollApproachIntervalsVP(time_div=0.25)[source]

Bases: lrn2.data.domain.viewpoint.ViewPoint

get_duration_from_raw_data(data)[source]
get_onset_from_raw_data(data)[source]
get_pitch_from_raw_data(data)[source]
raw_to_repr(raw_data, label)[source]
size
class lrn2.data.domain.music.PianoRollBeatInMeasureVP(time_div=0.5, max_depth=3)[source]

Bases: lrn2.data.domain.viewpoint.ViewPoint

get_duration_from_raw_data(data)[source]
get_onset_from_raw_data(data)[source]
get_time_signature_from_raw_data(data)[source]
raw_to_repr(raw_data, label)[source]
repr_to_visual(binary_data)[source]
size
t22 = [[0, 1]]
t24 = [[0, 0], [0, 1]]
t34 = [[0, 1, 1], [0, 0, 1]]
t38 = [[0, 0, 0], [0, 1, 1], [0, 0, 1]]
t44 = [[0, 0, 1, 1], [0, 1, 0, 1]]
t68 = [[0, 0, 0, 1, 1, 1], [0, 1, 1, 0, 1, 1], [0, 0, 1, 0, 0, 1]]
time_sigs = {'24': [[0, 0], [0, 1]], '38': [[0, 1, 1], [0, 0, 1]], '22': [[0, 1]], '44': [[0, 0, 1, 1], [0, 1, 0, 1]], '34': [[0, 1, 1], [0, 0, 1]], '68': [[0, 0, 0, 1, 1, 1], [0, 1, 1, 0, 1, 1], [0, 0, 1, 0, 0, 1]]}
class lrn2.data.domain.music.PianoRollIntervalsVP(time_div=0.25)[source]

Bases: lrn2.data.domain.viewpoint.ViewPoint

get_duration_from_raw_data(data)[source]
get_onset_from_raw_data(data)[source]
get_pitch_from_raw_data(data)[source]
raw_to_repr(raw_data, label)[source]
size
class lrn2.data.domain.music.PianoRollOffsetVP(min_pitch=0, max_pitch=128, time_div=0.25)[source]

Bases: lrn2.data.domain.music.PianoRollVP

raw_to_repr(raw_data, label)[source]
class lrn2.data.domain.music.PianoRollOnBeatVP(min_pitch=0, max_pitch=128, time_div=0.25)[source]

Bases: lrn2.data.domain.music.PianoRollVP

get_onset_from_raw_data(data)[source]
raw_to_repr(raw_data, label)[source]
class lrn2.data.domain.music.PianoRollOnsetVP(min_pitch=0, max_pitch=128, time_div=0.25)[source]

Bases: lrn2.data.domain.music.PianoRollVP

raw_to_repr(raw_data, label)[source]
class lrn2.data.domain.music.PianoRollPerceivedTensionAppVP(min_pitch, max_pitch, time_div=0.25, size=8, binary=True)[source]

Bases: lrn2.data.domain.music.PianoRollVP

TENSION_ORDER = [0, 7, 5, 4, 3, 2, 6, 1]
get_duration_from_raw_data(data)[source]
get_onset_from_raw_data(data)[source]
get_pitch_from_raw_data(data)[source]
interval_tension(intervals)[source]
raw_to_repr(raw_data, label)[source]
size
class lrn2.data.domain.music.PianoRollPerceivedTensionVP(min_pitch, max_pitch, time_div=0.25, size=8, binary=True)[source]

Bases: lrn2.data.domain.music.PianoRollVP

TENSION_ORDER = [0, 7, 5, 4, 3, 2, 6, 1]
get_duration_from_raw_data(data)[source]
get_onset_from_raw_data(data)[source]
get_pitch_from_raw_data(data)[source]
interval_tension(intervals)[source]
raw_to_repr(raw_data, label)[source]
size
class lrn2.data.domain.music.PianoRollPitchClassVP(min_pitch=0, max_pitch=128, time_div=0.25)[source]

Bases: lrn2.data.domain.music.PianoRollVP

raw_to_repr(raw_data, label)[source]
repr_to_visual(binary_data)[source]
size
class lrn2.data.domain.music.PianoRollPolyphonyVP(min_pitch=0, max_pitch=128, time_div=0.25, size=1)[source]

Bases: lrn2.data.domain.music.PianoRollVP

raw_to_repr(raw_data, label)[source]
size
class lrn2.data.domain.music.PianoRollRhythmVP(min_pitch=0, max_pitch=128, time_div=0.25, size=1)[source]

Bases: lrn2.data.domain.music.PianoRollVP

get_duration_from_raw_data(data)[source]
get_onset_from_raw_data(data)[source]
get_pitch_from_raw_data(data)[source]
raw_to_repr(raw_data, label)[source]
size
class lrn2.data.domain.music.PianoRollTonalTensionVP(min_pitch, max_pitch, time_div=0.25, size=8, context_width=17, binary=True)[source]

Bases: lrn2.data.domain.music.PianoRollVP

raw_to_repr(raw_data, label)[source]
size
class lrn2.data.domain.music.PianoRollTonalityVP(min_pitch=0, max_pitch=128, time_div=0.25, filt_width=17)[source]

Bases: lrn2.data.domain.music.PianoRollVP

raw_to_repr(raw_data, label)[source]
repr_to_visual(binary_data)[source]
size
class lrn2.data.domain.music.PianoRollVP(min_pitch=0, max_pitch=128, time_div=0.5, info=False, max_length=1e+16)[source]

Bases: lrn2.data.domain.viewpoint.ViewPoint

get_duration_from_raw_data(data)[source]
get_onset_from_raw_data(data)[source]
get_pitch_from_raw_data(data)[source]
raw_to_repr(raw_data, label)[source]
size
class lrn2.data.domain.music.PitchClassVP(modulo=12)[source]

Bases: lrn2.data.domain.viewpoint.ViewPoint

get_pitch_from_raw_data(data)[source]
raw_to_repr(raw_data, label)[source]
repr_to_visual(binary_data)[source]
size
class lrn2.data.domain.music.PitchContourVP[source]

Bases: lrn2.data.domain.viewpoint.ViewPoint

get_pitch_from_raw_data(data)[source]
raw_to_repr(raw_data, label)[source]
repr_to_visual(binary_data)[source]
size
class lrn2.data.domain.music.PitchIntervalAbsVP(max_abs_int=12)[source]

Bases: lrn2.data.domain.viewpoint.ViewPoint

get_pitch_from_raw_data(data)[source]
raw_to_repr(raw_data, label)[source]
repr_to_visual(binary_data)[source]
size
class lrn2.data.domain.music.PitchIntervalVP(max_abs_int=24)[source]

Bases: lrn2.data.domain.viewpoint.ViewPoint

get_pitch_from_raw_data(data)[source]
raw_to_repr(raw_data, label)[source]
repr_to_visual(binary_data)[source]
size
class lrn2.data.domain.music.PitchVP(min_pitch=0, max_pitch=128)[source]

Bases: lrn2.data.domain.viewpoint.ViewPoint

get_pitch_from_raw_data(data)[source]
raw_to_repr(raw_data, label)[source]
repr_to_visual(binary_data)[source]
size
lrn2.data.domain.music.chromagram(piano_roll, profile, filt_width=17)[source]
lrn2.data.domain.music.homophonic_sets(pitches, onsets, offsets, quant_thresh=0.1, min_dur_slice=0.0, min_sim_notes=0, include_multi_onsets=False)[source]

lrn2.data.domain.raw module

class lrn2.data.domain.raw.RawVP(size, sparse=False)[source]

Bases: lrn2.data.domain.viewpoint.ViewPoint

Viewpoint which returns the original raw data.

raw_to_repr(raw_data, label)[source]
repr_to_visual(binary_data)[source]
size

lrn2.data.domain.text module

class lrn2.data.domain.text.CharacterVP(sample=None, char_cat=None, suppress_warnings=False)[source]

Bases: lrn2.data.domain.viewpoint.ViewPoint

Converts character sequences into one-hot representations

Parameters:
  • sample (string, optional) – a sample string used to create a char catalog all characters which should be represented have to be included in this string
  • char_cat (dict, optional) – a dictionary with char -> integer pairs
catalog_chars(example)[source]
raw_to_repr(raw_data, label)[source]
size
class lrn2.data.domain.text.PartOfSpeechMarkerVP(dict_tags)[source]

Bases: lrn2.data.domain.viewpoint.ViewPoint

raw_to_repr(raw_data, label)[source]
size
class lrn2.data.domain.text.PartOfSpeechTargetsVP(dict_tags)[source]

Bases: lrn2.data.domain.viewpoint.ViewPoint

raw_to_repr(raw_data, label)[source]
size
class lrn2.data.domain.text.PartOfSpeechVP(dict_tags)[source]

Bases: lrn2.data.domain.viewpoint.ViewPoint

create_dict_map(dict_tags)[source]
create_one_hot_combinations(dict_tags)[source]
raw_to_repr(raw_data, label)[source]
size

lrn2.data.domain.viewpoint module

Created on Sep 11, 2014

@author: Maarten Grachten

class lrn2.data.domain.viewpoint.ViewPoint[source]

Bases: object

repr_to_visual(binary_data)[source]
size

Module contents