-
Notifications
You must be signed in to change notification settings - Fork 334
Open
Description
Hello,
I'm trying to use Magenta to generate a random melody.
I copied the test case:
magenta-js/music/src/music_rnn/model_test.ts
Lines 53 to 64 in 485b2cc
| test('MusicRNN can continue a sequence ', async (t: test.Test) => { | |
| const startMemory = tf.memory().numBytes; | |
| const temperature = 1; | |
| const continuation = | |
| await model.continueSequence(MEL_TEAPOT, 20, temperature); | |
| t.ok(continuation); | |
| t.true(continuation.notes.length > 0); | |
| // Doesn't leak memory. | |
| t.isEqual(tf.memory().numBytes, startMemory); | |
| t.end(); | |
| }); |
but I'm getting strange results, specifically I have 2 issues:
- When I use the temperature parameter, the output is empty
const melodyrnn = new mm.MusicRNN(
// "https://storage.googleapis.com/magentadata/js/checkpoints/music_rnn/melody_rnn"
"https://storage.googleapis.com/magentadata/js/checkpoints/music_rnn/basic_rnn"
);
const mel_teapot = {
notes: [
{ pitch: 69, quantizedStartStep: 0, quantizedEndStep: 2, program: 0 },
{ pitch: 71, quantizedStartStep: 2, quantizedEndStep: 4, program: 0 },
{ pitch: 73, quantizedStartStep: 4, quantizedEndStep: 6, program: 0 },
{ pitch: 74, quantizedStartStep: 6, quantizedEndStep: 8, program: 0 },
{ pitch: 76, quantizedStartStep: 8, quantizedEndStep: 10, program: 0 },
{ pitch: 81, quantizedStartStep: 12, quantizedEndStep: 16, program: 0 },
{ pitch: 78, quantizedStartStep: 16, quantizedEndStep: 20, program: 0 },
{ pitch: 81, quantizedStartStep: 20, quantizedEndStep: 24, program: 0 },
{ pitch: 76, quantizedStartStep: 24, quantizedEndStep: 32, program: 0 },
],
quantizationInfo: { stepsPerQuarter: 4 },
totalQuantizedSteps: 32,
};
async function generateMelody() {
try {
let resultSeq1 = await melodyrnn.continueSequence(mel_teapot, 15, 1);
let resultSeq2 = await melodyrnn.continueSequence(mel_teapot, 15);
console.log("resultseq notes", resultSeq1.notes); // this is empty
console.log("resultseq notes", resultSeq2.notes); // this is not empty
} catch (error) {
console.log("error", error);
}
}
- Even when the output is not empty, it is very repetitive. In the example above, resultsSeq2.notes is
[
Note {pitch: 52, quantizedStartStep: 4, quantizedEndStep: 7},
Note {pitch: 77, quantizedStartStep: 7, quantizedEndStep: 9},
Note {pitch: 76, quantizedStartStep: 9, quantizedEndStep: 10},
Note {pitch: 77, quantizedStartStep: 10, quantizedEndStep: 11},
Note {pitch: 77, quantizedStartStep: 11, quantizedEndStep: 12},
Note {pitch: 77, quantizedStartStep: 12, quantizedEndStep: 13},
Note {pitch: 77, quantizedStartStep: 13, quantizedEndStep: 14},
Note {pitch: 77, quantizedStartStep: 14, quantizedEndStep: 15}
]
At first there is some variety but then it just repeats pitch 77 (which isn't in the A major scale that the teapot melody uses)
What can I do to generate more unique melodies?
Thanks!
Metadata
Metadata
Assignees
Labels
No labels