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
""" | |
MIT License | |
Copyright (c) 2017 Cyrille Rossant | |
Permission is hereby granted, free of charge, to any person obtaining a copy | |
of this software and associated documentation files (the "Software"), to deal | |
in the Software without restriction, including without limitation the rights | |
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
copies of the Software, and to permit persons to whom the Software is |
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
# Working example for my blog post at: | |
# https://danijar.github.io/structuring-your-tensorflow-models | |
import functools | |
import tensorflow as tf | |
from tensorflow.examples.tutorials.mnist import input_data | |
def doublewrap(function): | |
""" | |
A decorator decorator, allowing to use the decorator to be used without |
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
% Complex step example. Requires Symbolic Math Toolbox. | |
format long | |
syms x; f = atan(x)/(1+exp(-x^2)) | |
% Derivative at $a = 2$: | |
a = 2; fd = double(subs( diff(f), a)) | |
% Convert symbolic function to MATLAB function. | |
f = matlabFunction(f); |
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 "fx.h" | |
#include <stddef.h> | |
#include <stdint.h> | |
#include <math.h> | |
#include <assert.h> | |
void static inline wht_butterfly(float * const s, float * const d) { | |
float temp = *s; | |
*s += *d; | |
*d = temp - *d; |
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 fd = complex_step(f,x,h) | |
%COMPLEX_STEP Complex step approximation to derivative. | |
% fd = COMPLEX_STEP(f,x,h) computes the complex step approximation | |
% fd to the derivative of f at x, using step h (default 1e-100). | |
if nargin < 3, h = 1e-100; end | |
fd = imag( f(x + sqrt(-1)*h) )/h; |
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 googletrans import Translator | |
from itertools import product | |
from pandas import DataFrame, read_csv | |
import numpy as np | |
import string | |
import time | |
import os | |
# Get google translator object | |
translator = Translator() |