Skip to content

Instantly share code, notes, and snippets.

View bluedistro's full-sized avatar
🏠
...

romann_empyre bluedistro

🏠
...
  • United Kingdom
View GitHub Profile
@bluedistro
bluedistro / decode_vector.py
Created December 31, 2018 14:25
Decode Vectorized data
# decode the words
reverse_word_index = dict([(value, key) for (key, value) in word_index.items()])
decoded_review = ' '.join([reverse_word_index.get(i, '?') for i in sequences[0]])
@bluedistro
bluedistro / code_1.py
Last active December 31, 2018 15:09
tokenization
# cut off reviews after 500 words
max_len = 500
# train on 10000 samples
training_samples = 10000
# validate on 10000 samples
validation_samples = 10000
# consider only the top 10000 words
max_words = 10000
# import tokenizer with the consideration for only the top 500 words
@bluedistro
bluedistro / code_0.py
Created December 31, 2018 14:18
data preprocessing
imdb_dir = '../datasets/aclImdb/aclImdb'
train_dir = os.path.join(imdb_dir, 'train')
labels = list()
texts = list()
# Processing the labels of the raw IMDB data
for label_type in ['neg', 'pos']:
dir_name = os.path.join(train_dir, label_type)
for fname in os.listdir(dir_name):
if fname[-4:] == '.txt':
@bluedistro
bluedistro / bankers_algorithm.py
Created November 6, 2018 18:23
Python Code to simulate Bankers algorithm as used in Operating Systems
# A python implementation of the Banker's Algorithm in Operating Systems using
# Processes and Resources
# {
# "Author: "Biney Kingsley (bluedistro@github.io)",
# "Date": 28-10-2018
# }
'''
The Banker's algorithm is a resource allocation and deadlock avoidance algorithm
developed by Edsger Dijkstra that tests for safety by simulating the allocation of
predetermined maximum possible amounts of all resources, and then makes a "s-state"