text
stringlengths
1
93.6k
args = parser.parse_args()
if torch.cuda.is_available():
device = torch.device('cuda')
elif torch.backends.mps.is_available():
device = torch.device('mps')
else:
device = torch.device('cpu')
whole_song_expr = WholeSongGeneration.init_pipeline(
frm_model_folder=args.mpath0,
ctp_model_folder=args.mpath1,
lsh_model_folder=args.mpath2,
acc_model_folder=args.mpath3,
frm_model_id=args.mid0,
ctp_model_id=args.mid1,
lsh_model_id=args.mid2,
acc_model_id=args.mid3,
debug_mode=args.debug,
device=None
)
whole_song_expr.main(
n_sample=args.nsample,
nbpm=4,
nspb=4,
phrase_string=args.pstring,
key=args.key,
is_major=args.minor,
demo_dir=args.demo_dir
)
# <FILESEP>
import numpy as np
import numpy.linalg as alg
import scipy as spy
import matplotlib.pyplot as plt
import time
from itertools import *
import sys
import math
import random
import datetime as DT
from matplotlib.dates import date2num
import multiprocessing
from sys import platform as _platform
#Find K breakpoints on the data at a specific lambda
#Returns: The K breakpoints, along with all intermediate breakpoints (for k < K) and their corresponding
# covariance-regularized maximum likelihoods
def GGS(data, Kmax, lamb, features = [], verbose = False):
data = data.T
#Select the desired features
if (features == []):
features = range(data.shape[1])
data = data[:,features]
m,n = data.shape
#Initialize breakpoints
breaks = [0,m+1]
breakPoints = [breaks[:]]
plotPoints = [calculateLikelihood(data, breaks,lamb)]
#Start GGS Algorithm
for z in range(Kmax):
numBreaks = z+1
newInd = -1
newVal = +1
#For each segment, find breakpoint and increase in LL
for i in range(numBreaks):
tempData = data[breaks[i]:breaks[i+1], :]
ind, val = addBreak(tempData, lamb)
if(val < newVal):
newInd = ind + breaks[i]
newVal = val
#Check if our algorithm is finished
if(newVal == 0):
print "We are done adding breakpoints!"
print breaks
return breaks, plotPoints
#Add new breakpoint
breaks.append(newInd)
breaks.sort()
if (verbose == True):
print "Breakpoint occurs at sample number: ", newInd, ", LL = ", newVal
print len(breaks) - 2, breaks
#Adjust current locations of the breakpoints
breaks = adjustBreaks(data,breaks,[newInd],lamb,verbose)[:]
#Calculate likelihood
ll = calculateLikelihood(data,breaks,lamb)
breakPoints.append(breaks[:])
plotPoints.append(ll)