From 962625919ffa2ce985fef4347215143e733f4513 Mon Sep 17 00:00:00 2001 From: Venkatesh S <47088590+Venseven@users.noreply.github.com> Date: Sat, 21 Sep 2019 20:09:49 +0530 Subject: [PATCH] utils.py python 3 version I have just tried to change python2x version to python3x version...Hope it'll help! --- utils.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/utils.py b/utils.py index 5a06dbd..2e00ca1 100755 --- a/utils.py +++ b/utils.py @@ -2,7 +2,7 @@ import math import random import os -import cPickle as pickle +import _pickle as pickle import xml.etree.ElementTree as ET from utils import * @@ -208,9 +208,13 @@ def to_one_hot(s, ascii_steps, alphabet): if len(seq) >= ascii_steps: seq = seq[:ascii_steps] else: - seq = seq + [0]*(ascii_steps - len(seq)) - one_hot = np.zeros((ascii_steps,len(alphabet)+1)) - one_hot[np.arange(ascii_steps),seq] = 1 + #print(ascii_steps - len(seq)) + seq = seq + np.multiply([0],(ascii_steps - len(seq))) + one_hot = np.zeros((int(ascii_steps),len(alphabet)+1)) + seq=np.array(seq,dtype=int) + seq=np.pad(seq,(0,len(np.arange(ascii_steps))-len(seq))) + + one_hot[np.arange(ascii_steps,dtype=int),seq] = 1 return one_hot # abstraction for logging @@ -221,6 +225,6 @@ def __init__(self, args): def write(self, s, print_it=True): if print_it: - print s + print(s) with open(self.logf, 'a') as f: f.write(s + "\n")