Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions AugmentedNet/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,14 @@ class DefaultArguments(object):
# "ChordRoot35",
"HarmonicRhythm7",
# "Inversion4",
"LocalKey35",
"LocalKey38",
"PitchClassSet121",
# "PrimaryDegree22",
"RomanNumeral31",
# "SecondaryDegree22",
"Soprano35",
"Tenor35",
"TonicizedKey35",
"TonicizedKey38",
],
"sequenceLength": 640,
"scrutinizeData": False,
Expand Down
4 changes: 2 additions & 2 deletions AugmentedNet/inference.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,8 +177,8 @@ def predict(model, inputPath):
if not notes:
continue
bass = sorted(notes, key=lambda n: n[1])[0][0]
thiskey = analysis.LocalKey35
tonicizedKey = analysis.TonicizedKey35
thiskey = analysis.LocalKey38
tonicizedKey = analysis.TonicizedKey38
pcset = analysis.PitchClassSet121
rn2, chordLabel = resolveRomanNumeral(
analysis.Bass35,
Expand Down
8 changes: 4 additions & 4 deletions AugmentedNet/output_representations.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,13 +142,13 @@ class SecondaryDegree22(OutputRepresentationTI):
dfFeature = "a_degree2"


class LocalKey35(OutputRepresentation):
class LocalKey38(OutputRepresentation):
classList = KEYS
dfFeature = "a_localKey"
transpositionFn = staticmethod(TransposeKey)


class TonicizedKey35(OutputRepresentation):
class TonicizedKey38(OutputRepresentation):
classList = KEYS
dfFeature = "a_tonicizedKey"
transpositionFn = staticmethod(TransposeKey)
Expand Down Expand Up @@ -180,10 +180,10 @@ class PitchClassSet121(OutputRepresentation):
"ChordRoot35": ChordRoot35,
"HarmonicRhythm7": HarmonicRhythm7,
"Inversion4": Inversion4,
"LocalKey35": LocalKey35,
"LocalKey38": LocalKey38,
"PitchClassSet121": PitchClassSet121,
"PrimaryDegree22": PrimaryDegree22,
"RomanNumeral31": RomanNumeral31,
"SecondaryDegree22": SecondaryDegree22,
"TonicizedKey35": TonicizedKey35,
"TonicizedKey38": TonicizedKey38,
}
12 changes: 6 additions & 6 deletions AugmentedNet/train.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,14 +163,14 @@ def evaluate(modelHdf5, X_test, y_true):
summary["Degree"] = df.Degree.mean().round(3)
print(f"Degree: {summary['Degree']}")
if (
"LocalKey35" in df
"LocalKey38" in df
and "ChordQuality11" in df
and "ChordRoot35" in df
and "Inversion4" in df
and "Degree" in df
):
df["RomanNumeral"] = (
df.LocalKey35
df.LocalKey38
& df.ChordQuality11
& df.ChordRoot35
& df.Inversion4
Expand All @@ -179,9 +179,9 @@ def evaluate(modelHdf5, X_test, y_true):
summary["RomanNumeral"] = df.RomanNumeral.mean().round(3)
print(f"RomanNumeral: {summary['RomanNumeral']}")
# The alternative approach proposed in Napoles Lopez et al. (2021)
if "RomanNumeral31" in df and "LocalKey35" in df and "Inversion4" in df:
if "RomanNumeral31" in df and "LocalKey38" in df and "Inversion4" in df:
df["AltRomanNumeral"] = (
df.RomanNumeral31 & df.LocalKey35 & df.Inversion4
df.RomanNumeral31 & df.LocalKey38 & df.Inversion4
)
summary["AltRomanNumeral"] = df.AltRomanNumeral.mean().round(3)
print(f"AltRomanNumeral: {summary['AltRomanNumeral']}")
Expand All @@ -191,10 +191,10 @@ def evaluate(modelHdf5, X_test, y_true):
and "Tenor35" in df
and "Alto35" in df
and "Soprano35" in df
and "LocalKey35" in df
and "LocalKey38" in df
):
df["satbRomanNumeral"] = (
df.Bass35 & df.Tenor35 & df.Alto35 & df.Soprano35 & df.LocalKey35
df.Bass35 & df.Tenor35 & df.Alto35 & df.Soprano35 & df.LocalKey38
)
summary["satbRomanNumeral"] = df.satbRomanNumeral.mean().round(3)
print(f"satbRomanNumeral: {summary['satbRomanNumeral']}")
Expand Down
4 changes: 2 additions & 2 deletions misc/evaluate_batch.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@


OUTPUTS = [
"LocalKey35",
"LocalKey38",
"ChordQuality15",
"Inversion4",
"ChordRoot35",
Expand Down Expand Up @@ -50,7 +50,7 @@ def evaluate(modelHdf5, X_test, y_true):
# Some custom features
df["Degree"] = df.PrimaryDegree22 & df.SecondaryDegree22
df["RomanNumeral"] = (
df.LocalKey35
df.LocalKey38
& df.ChordQuality15
& df.ChordRoot35
& df.Inversion4
Expand Down
12 changes: 6 additions & 6 deletions notebooks/AugmentedNet.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -138,12 +138,12 @@
"Alto35 (1, 640, 35)\n",
"Bass35 (1, 640, 35)\n",
"HarmonicRhythm7 (1, 640, 7)\n",
"LocalKey35 (1, 640, 38)\n",
"LocalKey38 (1, 640, 38)\n",
"PitchClassSet121 (1, 640, 121)\n",
"RomanNumeral31 (1, 640, 31)\n",
"Soprano35 (1, 640, 35)\n",
"Tenor35 (1, 640, 35)\n",
"TonicizedKey35 (1, 640, 38)\n",
"TonicizedKey38 (1, 640, 38)\n",
"/home/napulen/AugmentedNet-Copy/notebooks/AugmentedNet/AugmentedNet/inference.py:55: UserWarning: Boolean Series key will be reindexed to match DataFrame index.\n",
" return df.dropna()[df.HarmonicRhythm7 == 0]\n",
"Composer: J.S. Bach\n",
Expand Down Expand Up @@ -216,12 +216,12 @@
" <th>Alto35</th>\n",
" <th>Bass35</th>\n",
" <th>HarmonicRhythm7</th>\n",
" <th>LocalKey35</th>\n",
" <th>LocalKey38</th>\n",
" <th>PitchClassSet121</th>\n",
" <th>RomanNumeral31</th>\n",
" <th>Soprano35</th>\n",
" <th>Tenor35</th>\n",
" <th>TonicizedKey35</th>\n",
" <th>TonicizedKey38</th>\n",
" <th>offset</th>\n",
" <th>measure</th>\n",
" </tr>\n",
Expand Down Expand Up @@ -398,7 +398,7 @@
"</div>"
],
"text/plain": [
" Unnamed: 0 Alto35 Bass35 HarmonicRhythm7 LocalKey35 PitchClassSet121 \\\n",
" Unnamed: 0 Alto35 Bass35 HarmonicRhythm7 LocalKey38 PitchClassSet121 \\\n",
"0 0 E A 0 A (1, 4, 9) \n",
"1 1 E A 1 A (1, 4, 9) \n",
"2 2 E A 2 A (1, 4, 9) \n",
Expand All @@ -411,7 +411,7 @@
"638 638 C-- C-- 6 A (0, 1, 5, 8) \n",
"639 639 C-- C-- 6 A (0, 1, 5, 8) \n",
"\n",
" RomanNumeral31 Soprano35 Tenor35 TonicizedKey35 offset measure \n",
" RomanNumeral31 Soprano35 Tenor35 TonicizedKey38 offset measure \n",
"0 I A C# A 0.000 0.0 \n",
"1 I A C# A 0.125 0.0 \n",
"2 I A C# A 0.250 0.0 \n",
Expand Down
6 changes: 3 additions & 3 deletions notebooks/DebuggingResults.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
"metadata": {},
"outputs": [],
"source": [
"metrics = ['LocalKey35', 'PrimaryDegree22', 'SecondaryDegree22', 'ChordQuality15', 'Inversion4', 'ChordRoot35']\n",
"metrics = ['LocalKey38', 'PrimaryDegree22', 'SecondaryDegree22', 'ChordQuality15', 'Inversion4', 'ChordRoot35']\n",
"df6t[\"simultaneousCorrect\"] = 0\n",
"df6tsynth[\"simultaneousCorrect\"] = 0\n",
"for metric in metrics:\n",
Expand All @@ -61,7 +61,7 @@
"name": "stdout",
"output_type": "stream",
"text": [
"LocalKey35 - 6t: 0.978, 6tsynth: 0.9\n",
"LocalKey38 - 6t: 0.978, 6tsynth: 0.9\n",
"PrimaryDegree22 - 6t: 0.697, 6tsynth: 0.746\n",
"SecondaryDegree22 - 6t: 0.948, 6tsynth: 0.938\n",
"ChordQuality15 - 6t: 0.672, 6tsynth: 0.726\n",
Expand All @@ -71,7 +71,7 @@
}
],
"source": [
"# metrics = ['LocalKey35', 'Degree', 'ChordQuality15', 'Inversion4', 'ChordRoot35', 'RomanNumeral']\n",
"# metrics = ['LocalKey38', 'Degree', 'ChordQuality15', 'Inversion4', 'ChordRoot35', 'RomanNumeral']\n",
"samples = 2000\n",
"for metric in metrics:\n",
" print(f\"{metric} - 6t: {df6t[metric][:samples].mean().round(3)}, 6tsynth: {df6tsynth[metric][:samples].mean().round(3)}\")"
Expand Down
Loading