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
def flatten(*parents, dtype=tuple): | |
# internally, lists are used because they can be easily merged and expanded | |
result = list() | |
for i in range(len(parents)): | |
try: | |
# if i-th element iterable, use recursion to flatten all its elements and merge the result with current return list | |
result.extend(flatten(*parents[i], dtype=list)) | |
except TypeError: | |
# if not iterable, add the element to return list | |
result.append(parents[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
#include <stdio.h> | |
#include <stdint.h> | |
float pwr2(float x) | |
{ | |
return x * x; | |
} | |
float inv_sqrt(float number) | |
{ |
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
#include "lib_math_vectors.h" | |
// Simplifies math power function | |
double pow2(double x) { return pow(x, 2); } | |
// Sigmoidal function | |
double sigmoid(double x) { return 1.0 / (1.0 + exp(-x)); } | |
// ReLU function | |
double relu(double x) { return fmax(0.0, x); } |
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
#include "md5.h" | |
const uint32_t r[] = {7, 12, 17, 22, 7, 12, 17, 22, 7, 12, 17, 22, 7, 12, 17, 22, | |
5, 9, 14, 20, 5, 9, 14, 20, 5, 9, 14, 20, 5, 9, 14, 20, | |
4, 11, 16, 23, 4, 11, 16, 23, 4, 11, 16, 23, 4, 11, 16, 23, | |
6, 10, 15, 21, 6, 10, 15, 21, 6, 10, 15, 21, 6, 10, 15, 21}; | |
const uint32_t k[] = { | |
0xd76aa478, 0xe8c7b756, 0x242070db, 0xc1bdceee, | |
0xf57c0faf, 0x4787c62a, 0xa8304613, 0xfd469501, |
NewerOlder