コード例 #1
0
li = li[:size]

print "Preparing dictionaries..."
if dense: vdict = util.lstmvec(dictfile)
else: charset = util.make_charset(li,7)

print "Preparing datasets..."

dataset_train = li[:cut1]
dataset_validate = li[cut1:cut2]
dataset_test = li[cut2:]

dataset = []
while dataset_train:
    x, y = util.line_toseq(dataset_train.pop(), charstop)
    if dense: dataset.append(util.seq_to_densevec(x, y, vdict))
    else: dataset.append(util.seq_to_sparsevec(x,y,charset))
    if not len(dataset_train)%1000: print "len(dataset_train)", len(dataset_train)
dataset_train = dataset

dataset = []
while dataset_validate:
    x, y = util.line_toseq(dataset_validate.pop(), charstop)
    if dense: dataset.append(util.seq_to_densevec(x, y, vdict))
    else: dataset.append(util.seq_to_sparsevec(x,y,charset))
    if not len(dataset_validate)%1000: print "len(dataset_validate)", len(dataset_validate)
dataset_validate = dataset


#sys.exit()
print("Preparing dictionaries...")
if dense: vdict = util.lstmvec(dictfile)
else: charset = util.make_charset(li, 7)

print("Preparing datasets...")
dataset_train = li[:cut1]
dataset_validate = li[cut1:cut2]
dataset_test = li[cut2:]

dataset = []
print(type(dataset_train))

while dataset_train:
    x, y = util.line_toseq(dataset_train.pop(), charstop)
    if dense: dataset.append(util.seq_to_densevec(x, y, vdict))
    else: dataset.append(util.seq_to_sparsevec(x, y, charset))
    if not len(dataset_train) % 1000:
        print("len(dataset_train)", len(dataset_train))
dataset_train = dataset

dataset = []
while dataset_validate:
    x, y = util.line_toseq(dataset_validate.pop(), charstop)
    if dense: dataset.append(util.seq_to_densevec(x, y, vdict))
    else: dataset.append(util.seq_to_sparsevec(x, y, charset))
    if not len(dataset_validate) % 1000:
        print("len(dataset_validate)", len(dataset_validate))
dataset_validate = dataset

dataset = []