+6
-1
@@ -1,6 +1,7 @@
|
||||
"""Explicit, deterministic supervised training; never called by an asset build."""
|
||||
from __future__ import annotations
|
||||
import argparse
|
||||
import collections
|
||||
import dataclasses
|
||||
import hashlib
|
||||
import json
|
||||
@@ -49,6 +50,8 @@ def load_examples(manifest):
|
||||
if evidence['discrepancies']:raise ValueError(entry['id']+': '+str(evidence['discrepancies']))
|
||||
ctx=Context(document)
|
||||
training_io.validate_harmony(document,evidence,entry['id'])
|
||||
from generator.solo.authored import validate_evidence
|
||||
checked=validate_evidence(document,evidence)
|
||||
events=[];cursor=F()
|
||||
from generator import fretboard
|
||||
for n in evidence['sounding_events']:
|
||||
@@ -61,7 +64,8 @@ def load_examples(manifest):
|
||||
events.append((start,end,pitch));cursor=end
|
||||
if cursor<a.boundaries[-1]:events.append((cursor,a.boundaries[-1],None))
|
||||
source_hash=hashlib.sha256(source.read_bytes()).hexdigest()
|
||||
examples.append({'id':entry['id'],'song':source_hash,'role':role,'analysis':a,'harmony':ctx,'events':tuple(events)})
|
||||
examples.append({'id':entry['id'],'song':source_hash,'role':role,'analysis':a,'harmony':ctx,'events':tuple(events),
|
||||
'harmonic_validation':{'valid':checked.valid,'treatments':dict(sorted(collections.Counter(c.rule for c in checked.contracts).items()))}})
|
||||
provenance.append({'id':entry['id'],'source_sha256':source_hash,'solo_sha256':evidence['sha256'],
|
||||
'pitch_convention':entry['pitch_convention'],'measures':len(spans),'pickup_beats':str(a.body_offset),
|
||||
'slot':entry['slot'],'attacks':len(evidence['sounding_events']),'annotations':len(evidence['annotations']),
|
||||
@@ -136,6 +140,7 @@ def main():
|
||||
value=learned.fit(examples,provenance);predictor=learned.Model(value)
|
||||
report={'version':learned.VERSION,'training':provenance,'model_sha256':vocabulary.fingerprint(value),
|
||||
'contexts':len(value['contexts']),'in_sample_event_nll':{e['id']:likelihood(predictor,e) for e in examples},
|
||||
'harmonic_validation':{e['id']:e['harmonic_validation'] for e in examples},
|
||||
'limitations':'A small corpus does not establish generalization. Likelihood is teacher-forced, not free generation or musical preference.'}
|
||||
if args.leave_one_song_out:
|
||||
report['held_out_event_nll']={}
|
||||
|
||||
Reference in New Issue
Block a user