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 | |
from numpy import * | |
from random import randint | |
max_length = 2 | |
batch_size = 3 | |
label = array([[[0,0] for _ in range(max_length)] for _ in range(batch_size)]) | |
for i in range(batch_size): | |
for j in range(max_length): |
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 | |
from numpy import * | |
from random import randint | |
max_length = 3 | |
batch_size = 5 | |
targets = array([[1 for _ in range(max_length)] for _ in range(batch_size)]) | |
logits = array([[[randint(0,10)/10,randint(0,10)/10] for _ in range(max_length)] for _ in range(batch_size)]) | |
sequence_length = array([randint(1,max_length) for _ in range(batch_size)]) |
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 math | |
import numpy as np | |
def get_cosh(x): | |
N = 100000 | |
t = 0.0 | |
for i in range(0, N): | |
t += math.pow(x,2*i)*1.0/math.factorial(2*i)*1.0 | |
return 2 * t * 1.0 / 2 |
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
function top = nms(boxes, overlap) | |
% top = nms_fast(boxes, overlap) | |
% Non-maximum suppression. (FAST VERSION) | |
% Greedily select high-scoring detections and skip detections | |
% that are significantly covered by a previously selected | |
% detection. | |
% NOTE: This is adapted from Pedro Felzenszwalb's version (nms.m), | |
% but an inner loop has been eliminated to significantly speed it | |
% up in the case of a large number of boxes | |
% Tomasz Malisiewicz (tomasz@cmu.edu) |
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 argparse | |
parser = argparse.ArgumentParser(description='Main Application') | |
parser.add_argument('--n',type=str,default='magic',help='name of dataset') | |
parser.add_argument('--m',type=str,default='m11',help='method name(11,21,22)') | |
parser.add_argument('--dr',type=int,default=1,help='random state of train_test_split') | |
args = parser.parse_args() | |
train_X, test_X, label_X, label_Y = get_data(args.n, args.dr) |
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
#include <stdio.h> | |
#include <xmmintrin.h> | |
int main(){ | |
short in1[] = {1,2,3,4}; | |
short in2[] = {2,3,4,5}; | |
int out1; | |
int out2; | |
__m64 m1; | |
__m64 m2; | |
__m128 m128; |
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
from retrying import retry | |
from random import random | |
@retry(stop_max_attempt_number=7) | |
def do(): | |
if random() > 0.5: | |
print('Success!') | |
else: | |
print('Fail!') | |
raise |
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
python中try/except/else/finally语句的完整格式如下所示: | |
try: | |
Normal execution block | |
except A: | |
Exception A handle | |
except B: | |
Exception B handle | |
except: | |
Other exception handle | |
else: |
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 | |
def drop_first_last(grades): | |
first, *middle, last = grades | |
return middle | |
def args(*args): | |
for value in args: | |
print(value) |
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
def dropout(x, level, noise_shape=None, seed=None): | |
"""Sets entries in `x` to zero at random, while scaling the entire tensor. | |
# Arguments | |
x: tensor | |
level: fraction of the entries in the tensor | |
that will be set to 0. | |
noise_shape: shape for randomly generated keep/drop flags, | |
must be broadcastable to the shape of `x` |