This file contains 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
N = int(input()) | |
input_num = input().split(" ") | |
input_num = [int(num) for num in input_num] | |
def change(result_list, num): | |
for i in range(len(result_list)-1,-1,-1): | |
if(result_list[i] > num): | |
idx = i | |
else: | |
break |
This file contains 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 re | |
line = "I don't go to school--with you ========== ------------ ........ *******" | |
re.sub(r"(\W)\1+", r"\1" , line) |
This file contains 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 tensorflow as tf | |
import numpy as np | |
input_data = np.random.rand(10, 10, 64) | |
positions = [0,9,8,2,3,5,1,2,4,6] | |
input_tensor = tf.placeholder(shape = (None,10,64) , dtype = tf.float32) | |
positions_tensor = tf.placeholder(shape = (None,) , dtype = tf.int32) |
This file contains 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
x = [1,2,3,4,5,6,7,8,9,10] | |
total_case = [] | |
for i in x: | |
first = [i] | |
for j in x: | |
c_first = list(first) | |
if(i < j): | |
c_first.append(j) |
This file contains 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 tensorflow as tf | |
max_seq_len = 6 | |
seq_len = [3,5,4] | |
row_vector = tf.range(0,max_seq_len,1) ## [, max_seq_len] | |
matrix = tf.cast(tf.expand_dims(seq_len,-1), tf.int32) ## [batch_size, 1] | |
t = tf.cast(row_vector < matrix, tf.float32) ## [batch_size, max_seq_len] | |
t = tf.expand_dims(t, -1) ## [batch_size, max_seq_len, 1] |
This file contains 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
# -*- coding: utf-8 -*- | |
""" | |
Created on Sat Apr 6 10:47:30 2019 | |
@author: jbk48 | |
""" | |
from keras.layers import Layer | |
import tensorflow as tf |
This file contains 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 tensorflow as tf | |
g = tf.Graph() | |
with g.as_default(): | |
a = tf.Variable(initial_value=[[1, 2, 4, 0],[2, 4, 5, 8]]) | |
b = tf.scatter_update(a, [0], [[0, 0, 0, 0]]) | |
with tf.Session(graph=g) as sess: | |
sess.run(tf.initialize_all_variables()) | |
print(sess.run(a)) |
This file contains 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 numpy as np | |
import tensorflow as tf | |
batch_size = 3 | |
max_seq_len = 5 | |
dim = 4 | |
input_data = tf.placeholder(shape = (None,max_seq_len,dim), dtype = tf.float32) | |
seq_len = tf.placeholder(shape = [None], dtype = tf.int32) |
This file contains 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 tensorflow as tf | |
# Constants (3-element arrays). | |
a = tf.constant([100, 200, 300]) | |
b = tf.constant([1, 2, 3]) | |
# Use placeholder for predicate to where. | |
# ... We pass in an array of 3 bools to fill the placeholder. | |
j = tf.placeholder(tf.bool, [3]) |
This file contains 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 random | |
a = ['a', 'b', 'c'] | |
b = [1, 2, 3] | |
c = list(zip(a, b)) | |
random.shuffle(c) | |
a, b = zip(*c) |