Exemplo n.º 1
0
    def __init__(self, startPointer):
        #self.length = length # 16 * 4 * n
        self.rythm_seq = np.zeros(0)  #1
        self.rythm_seq_base = base_Patterns(startPointer)
        self.harmony_seq = np.zeros(0)  #2
        self.harmony_seq_base = base_Patterns(startPointer)

        # 1 2消えちゃった時用
        self.etc1_seq = np.zeros(0)  #
        self.etc1_seq_base = base_Patterns(startPointer)
        self.harmony_off = True
        self.rythm_off = True
        """
        現状、大きくHarmonic, Rytmicなものの状態遷移があり、その中でON OFFを決めていく
        Each part-index is
        hold = 0 0は必ずhold
        rythm = 1
        harmony = 2
        """
        self.node_prob_control = func.softmax([0.1, 0.1, 0.2])

        # OUT / LOOP
        self.loopWeight = {}
        self.loopWeight[0] = func.softmax([0.8, 0.1]).tolist()
        self.loopWeight[1] = func.softmax([0.8, 0.2]).tolist()
        self.loopWeight[2] = func.softmax([0.0, 0.2]).tolist()
Exemplo n.º 2
0
 def __init__(self):
     #self.pitchWeight_a = [5.5, 1.5, 5, 1.5, 5, 5, 1.5, 5.1, 1.5, 5, 1.5, 5]
     self.pitchWeight_a = [5.5, 0, 5, 0, 5, 6, 0, 5.1, 0, 0, 0, 8]
     self.degreeWeight_a = [
         1, 0.1, 2, 1.2, 1.2, 0.7, 0.7, 0.7, 1.2, 1.2, 2, 1.2
     ]
     self.pitchWeight = func.softmax(self.pitchWeight_a, t=0.2)
     self.degreeWeight = func.softmax(self.degreeWeight_a)
Exemplo n.º 3
0
 def restore(self, input):
     saver = tf.train.Saver()
     saver.restore(self.nnw.sess, self.ckpt_dir)
     input = input.reshape(1, len(input))
     output = self.nnw.sess.run(self.nnw.output,
                                feed_dict={self.nnw.X: input})
     return func.dice(func.softmax(np.array(output[0, ]), t=0.1))
Exemplo n.º 4
0
 def translateMelody(self, melody, t=0.5):
     output = []
     oneNote = np.zeros(12)
     for i in range(len(melody)):
         if melody[i] != -1:
             oneNote[melody[i]] = oneNote[melody[i]] + 1
     return func.softmax(oneNote, t=t)
Exemplo n.º 5
0
def pickUpAccent(melody, notePerBar_n=16):
    output = np.zeros(0)
    oneBar = np.zeros(len(melody))

    for j in range(int(len(melody) / notePerBar_n)):
        for i in range(notePerBar_n):
            if melody[notePerBar_n * j + i] != -1:
                oneBar[notePerBar_n * j + i] = oneBar[notePerBar_n * j + i] + 1
    output = np.r_[output, func.softmax(oneBar)]
    return output
Exemplo n.º 6
0
def predict(network, x):
    W1, W2, W3 = network['W1'], network['W2'], network['W3']
    b1, b2, b3 = network['b1'], network['b2'], network['b3']

    a1 = np.dot(x, W1) + b1
    z1 = sigmoid(a1)
    a2 = np.dot(z1, W2) + b2
    z2 = sigmoid(a2)
    a3 = np.dot(z2, W3) + b3
    y = softmax(a3)
    return y
Exemplo n.º 7
0
def Create(melody, notePerBar_n = 16, barsPerOneSection = 4, temperature = 0.0005):
    merge =  pickUpAccent(melody, notePerBar_n) * pickUpSectionAccent(melody, notePerBar_n, barsPerOneSection)

    output = np.zeros(0)
    oneBar = np.zeros(notePerBar_n)

    for j in range(int(len(merge)/notePerBar_n )):
        for i in range(notePerBar_n ):
            oneBar[i] = merge[j*notePerBar_n  + i]
        output = np.r_[output, func.softmax(oneBar, t = temperature)] #0.0005がちょうどよい
        oneBar = np.zeros(notePerBar_n )
    return output
Exemplo n.º 8
0
    def __init__(self):
        self.master = func.softmax([0.1 ,0.1 ,0.1 ,0.15,0.1, 0.01, 0.01])

        self.noteWeight = {}
        self.sequence = np.zeros(0)
        # OUT / LOOP
        self.noteWeight[0] = func.softmax([0.5,0.5]).tolist() #Lead1
        self.noteWeight[1] = func.softmax([0.5,0.5]).tolist() #Lead2
        self.noteWeight[2] = func.softmax([0.5,0.1]).tolist() #Bucking
        self.noteWeight[3] = func.softmax([0.5,0.6]).tolist() #Bass
        self.noteWeight[4] = func.softmax([0.4,0.2]).tolist() #HiHat
        self.noteWeight[5] = func.softmax([0.4,0.2]).tolist() #Snare
        self.noteWeight[6] = func.softmax([0.4,0.2]).tolist() #BaDrum

        self.loopFlg = True
Exemplo n.º 9
0
    def updatePW(self, pw_a, std_f='softmax', t=0.05):
        """
        pw_a は numpy
        """
        self.pitchWeight_a = pw_a

        if std_f == 'softmax':
            self.pitchWeight = func.softmax(self.pitchWeight_a, t=t)

        elif std_f == 'simpleStd':
            self.pitchWeight = func.simpleStd(self.pitchWeight_a)

        else:
            self.pitchWeight = func.simpleStd(self.pitchWeight_a)
Exemplo n.º 10
0
def pickUpSectionAccent(melody, notePerBar_n = 16, barsPerOneSection = 4):
    output = np.zeros(0)
    oneBar = np.zeros(notePerBar_n)

    # minimum beat length sixteen-beat and then 16
    for j in range(int(len(melody)/notePerBar_n)):
        for i in range(notePerBar_n):
            if melody[j*notePerBar_n + i] > -1:
                oneBar[i] = oneBar[i]  + 1
        if j % barsPerOneSection == barsPerOneSection - 1:
            for k in range(barsPerOneSection):
                output = np.r_[output, func.softmax(oneBar)] #ランダム性はコントロールできる。*3でいけないのか。
            oneBar = np.zeros(notePerBar_n)
    return output
Exemplo n.º 11
0
    def updateRelPW(self, pitchIndex, std_f='softmax'):
        if pitchIndex > 0:
            tmpDegreeWeight = np.r_[self.degreeWeight[12 - pitchIndex:],
                                    self.degreeWeight[0:12 - pitchIndex]]
        else:
            tmpDegreeWeight = self.degreeWeight

        if std_f == 'softmax':
            self.relPitchWeight = func.softmax(self.pitchWeight *
                                               tmpDegreeWeight)
        elif std_f == 'simpleStd':
            self.relPitchWeight = func.simpleStd(self.pitchWeight *
                                                 tmpDegreeWeight)
        else:
            self.relPitchWeight = func.simpleStd(self.pitchWeight *
                                                 tmpDegreeWeight)
Exemplo n.º 12
0
    def setWeight(self):
        # OUT / LOOP
        #ON
        self.noteWeight[0] = func.softmax([0.5, 0.5]).tolist()
        self.noteWeight[1] = func.softmax([0.5, 0.5]).tolist()
        self.noteWeight[2] = func.softmax([0.5, 0.8]).tolist()
        self.noteWeight[3] = func.softmax([0.5, 0.6]).tolist()
        self.noteWeight[4] = func.softmax([0.4, 0.5]).tolist()
        #OFF
        self.noteWeight[5] = func.softmax([0.5, 0.5]).tolist()
        self.noteWeight[6] = func.softmax([0.5, 0.5]).tolist()
        self.noteWeight[7] = func.softmax([0.5, 0.5]).tolist()
        self.noteWeight[8] = func.softmax([0.5, 0.5]).tolist()
        self.noteWeight[9] = func.softmax([0.5, 0.5]).tolist()

        self.noteWeightMaster = func.softmax(
            [7, 4, 6, 8, 5, 1, 1, 1.5, 1.5, 1])
 def predict(self, X):
     self.a = np.dot(X, self.W)
     self.z = sigmoid(self.a)
     self.y = softmax(self.z)
     return self.y
Exemplo n.º 14
0
 def updateDW(self, t):
     self.degreeWeight = func.softmax(self.degreeWeight_a, t=t)
Exemplo n.º 15
0
    def loss(self, x, t):
        z = self.predict(x)
        y = softmax(z)
        loss = cross_entropy_error(y, t)

        return loss