def load_multiple(participant, series, data_selector=None, shuffle=True):
    '''
    this is a wrapper for load_eeg_emg in order to be able to load more than one person/session at once.

    for more information look at load_emg_emg

    :param participant list e.g. [1, 2, 5]
    :param series list [1, 2, 3, 7]
    :param data_selector "eeg", "emg" or None (default), if both data should be loaded.
    :param shuffle determines if data should be shuffled randomly

    :return: list of dicts of eeg, emg data
    '''

    data = []
    for p in participant:
        download_way_eeg_gal(p)
        unzip_way_eeg_gal(p)
        for s in series:
            data_tmp, eventNames = get_eeg_emg(p, s, data_selector)
            data = data + data_tmp

    if shuffle:
        shuf(data)

    return data, eventNames
示例#2
0
def load_multiple(participant, series, data_selector=None, shuffle=True):
    '''
    this is a wrapper for load_eeg_emg in order to be able to load more than one person/session at once.

    for more information look at load_emg_emg

    :param participant list e.g. [1, 2, 5]
    :param series list [1, 2, 3, 7]
    :param data_selector "eeg", "emg" or None (default), if both data should be loaded.
    :param shuffle determines if data should be shuffled randomly

    :return: list of dicts of eeg, emg data
    '''

    data = []
    for p in participant:
        download_way_eeg_gal(p)
        unzip_way_eeg_gal(p)
        for s in series:
            data_tmp, eventNames = get_eeg_emg(p, s, data_selector)
            data = data + data_tmp

    if shuffle:
        shuf(data)

    return data, eventNames
示例#3
0
    def resetDeck(self):
         #Initializes deck
        NewDeck = [EuchreCard(s,r) for s in [SUITS.hearts,SUITS.spades,SUITS.diamonds,SUITS.clubs]
						 for r in [RANKS.nine,RANKS.ten,RANKS.jack,RANKS.queen,RANKS.king,RANKS.ace]]

        shuf(NewDeck) #Shuffles deck
        return NewDeck
示例#4
0
def iterateOnFold(fold, shuffle=False):
    global lista
    nb = 0
    lista = os.listdir(fold)
    global path
    path = fold
    if shuffle:
        shuf(lista)
    else:
        lista.sort()
示例#5
0
    def __getitem__(self, batch_index):
        """
        Generates a batch of correctly shaped X and Y data

        :param batch_index: index of the batch to generate
        :return: input dictionary containing:
                'the_input':     np.ndarray[shape=(batch_size, max_seq_length, mfcc_features)]: input audio data
                'the_labels':    np.ndarray[shape=(batch_size, max_transcript_length)]: transcription data
                'input_length':  np.ndarray[shape=(batch_size, 1)]: length of each sequence (numb of frames) in x_data
                'label_length':  np.ndarray[shape=(batch_size, 1)]: length of each sequence (numb of letters) in y_data
                 output dictionary containing:
                'ctc':           np.ndarray[shape=(batch_size, 1)]: dummy data for dummy loss function

        """

        # Generate indexes of current batch
        indexes_in_batch = self.indexes[batch_index *
                                        self.batch_size:(batch_index + 1) *
                                        self.batch_size]

        # Shuffle indexes within current batch if shuffle=true
        if self.shuffle:
            shuf(indexes_in_batch)

        # Load audio and transcripts
        x_data_raw, y_data_raw, sr = load_audio(self.df, indexes_in_batch)

        # Preprocess and pad data
        x_data, input_length = self.extract_features_and_pad(x_data_raw, sr)
        y_data, label_length = convert_and_pad_transcripts(y_data_raw)

        # print ("\nx_data shape: ", x_data.shape)
        # print ("y_data shape: ", y_data.shape)
        # print ("input_length shape: ", input_length.shape)
        # print ("label_length shape: ", label_length.shape)
        # print ("input length: ", input_length)
        # print ("label_length: ", label_length, "\n")

        inputs = {
            'the_input': x_data,
            'the_labels': y_data,
            'input_length': input_length,
            'label_length': label_length
        }

        outputs = {
            'ctc': np.zeros([self.batch_size])
        }  # dummy data for dummy loss function

        return inputs, outputs
示例#6
0
    def __getitem__(self, batch_index):
        indices_in_batch = self.indices[batch_index *
                                        self.batch_size:(batch_index + 1) *
                                        self.batch_size]
        if self.shuffle:
            shuf(indices_in_batch)

        x_data = np.zeros((self.batch_size, self.max_frames, self.feature))
        targets = []
        paths = self.load_data(indices_in_batch)
        for count, i in enumerate(paths):
            frames, label = self.extract_feature(i)
            self.classes.append(label)
            targets.append(label)
            x_data[count] = frames

        outputs = np.asarray(targets)
        return x_data, outputs
示例#7
0
 def shuffle(self):
     shuf(self.cards)
示例#8
0
文件: deck.py 项目: mnowotka/pypoker
 def shuffle(self):
     shuf(self)
示例#9
0
from random import choice as ch, shuffle as shuf
from custom_module import tab, new_line as nl

print("I am in: " + __name__)
nl()
print(ch(["apple", "banana", "cherry", "durian"]))
nl()
nl()
tab()
tab()
print(shuf(["apple", "banana", "cherry", "durian"]))
示例#10
0
model = build_model()
model.summary()

np.random.seed(312)
num_epochs = 5
batch_size = 2

path = 'dataset/train'
data_train = []

for r, d, f in os.walk(path):
    for _f in f:
        data_train.append(os.path.join(r, _f))

shuf(data_train)
data_train = np.asarray(data_train)

path = 'dataset/validate'
data_validate = []

for r, d, f in os.walk(path):
    for _f in f:
        data_validate.append(os.path.join(r, _f))

shuf(data_validate)
data_validate = np.asarray(data_validate)
path = 'dataset/test'
data_test = []

for r, d, f in os.walk(path):
示例#11
0
 def test_random(self):
     assert random.random() < 1
     assert random.randint(1, 10) in list(range(10))
     assert random.choice([1, 3, 5]) in list([1, 3, 5])
     # alias to random.shuffle
     shuf([1, 2, 3])  # shuffles the list, mutable operation
示例#12
0
 def shuffle(self):
     shuf(self.cards)