This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
t = int(input()) | |
for r in range(1, t + 1): | |
n = int(input()) | |
m = [] | |
for _ in range(n): | |
m.append(input()) | |
fin_by = set() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
t = int(input()) | |
for r in range(1, t + 1): | |
s = input() | |
k = int(input()) | |
mapper = {} | |
target = set() | |
level = {f"{i}{i}": 0 for i in s} | |
for _ in range(k): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
t = int(input()) | |
for r in range(1, t + 1): | |
s = input() | |
n = len(s) | |
m = float("inf") | |
for i in range(26): | |
counter = 0 | |
curr = chr(ord("A") + i) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
test_images[['image', 'annotated_predictions']].explore() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# load model | |
model = tc.load_model('./pokemon_5000.model') | |
# read images | |
test_images = tc.SFrame({'image':[tc.Image('dataset/pokemon_test1.jpg'), | |
tc.Image('dataset/pokemon_test2.jpeg'), | |
tc.Image('dataset/pokemon_test3.jpg'), | |
tc.Image('dataset/pokemon_test4.jpeg')]}) | |
# predict |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import turicreate as tc | |
starter_images = tc.SFrame({'image':[tc.Image('dataset/pokemon.png')], 'label':['pokemon']}) | |
model = tc.one_shot_object_detector.create(starter_images, 'label', max_iterations=5000) | |
model.save('pokemon_5000.model') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
f = open('ach_output.txt', 'w') | |
t = int(input()) | |
for i in range(t): | |
n = int(input()) | |
s = input() | |
a = s.count('A') | |
b = s.count('B') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
f = open('output.txt', 'w') | |
t = int(input()) | |
for a in range(t): | |
n = int(input()) | |
i = input() | |
o = input() | |
result = [] | |
for b in range(n): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
model = Sequential() | |
model.add(Bidirectional(LSTM(128), input_shape=(SEQUENCE_LEN, len(words)))) | |
model.add(Dense(len(words))) | |
model.add(Activation("softmax")) | |
model.compile(loss="categorical_crossentropy", optimizer="adam", metrics=["accuracy"]) | |
model.fit_generator( | |
generator(sentences, next_words, BATCH_SIZE), | |
steps_per_epoch=int(len(sentences) / BATCH_SIZE) + 1, | |
epochs=EPOCHS, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
word_indices = dict((c, i) for i, c in enumerate(words)) | |
indices_word = dict((i, c) for i, c in enumerate(words)) | |
for i in range(0, len(text_in_words) - SEQUENCE_LEN): | |
if (len(set(text_in_words[i : i + SEQUENCE_LEN + 1]).intersection(ignored_words)) == 0): | |
sentences.append(text_in_words[i : i + SEQUENCE_LEN]) | |
next_words.append(text_in_words[i + SEQUENCE_LEN]) |
NewerOlder