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 logging | |
| from foolbox.utils import onehot_like | |
| from foolbox.attacks.base import Attack | |
| from foolbox.attacks.base import generator_call_decorator | |
| import numpy as np | |
| from numba import jitclass | |
| import line_profiler |
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
| from numba import njit | |
| @njit | |
| def square(x, y): | |
| return x * y | |
| @njit | |
| def closure(y): | |
| return lambda x: square(x, y) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 get_vgg19(file='vgg19.pkl', leak=0, only_mean=False): | |
| if leak == 0: | |
| rectify = lasagne.nonlinearities.rectify | |
| else: | |
| rectify = LeakyRectify(leak) | |
| def build_model(): | |
| net = {} | |
| net['input'] = InputLayer((None, 3, 224, 224)) |
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
| cimport cython | |
| cimport numpy as np | |
| from libc.math cimport log, exp, sqrt, sin | |
| import numpy as np | |
| @cython.boundscheck(False) | |
| @cython.wraparound(False) | |
| @cython.cdivision(True) | |
| def c_analytic_simulate(np.ndarray[double, ndim=2] A, np.ndarray[double, ndim=2] T, np.ndarray[double, ndim=2] Of, |
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
| blas_set_num_threads(1) | |
| function train_network(A, T, Of, cs, dt) | |
| I, N = size(T) | |
| z = zeros(I) | |
| r = zeros(N) | |
| Az = Array(Float64, I) | |
| Ofr = Array(Float64, N) | |
| I_teach = Array(Float64, N) | |
| Tz = Array(Float64, 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
| import os | |
| os.environ['THEANO_FLAGS'] = 'device=gpu0, assert_no_cpu_op=raise, on_unused_input=ignore, floatX=float32' | |
| from __future__ import absolute_import | |
| from __future__ import print_function | |
| from keras.datasets import cifar10 | |
| from keras.preprocessing.image import ImageDataGenerator | |
| from keras.models import Sequential | |
| from keras.layers.core import Dense, Dropout, Activation, Flatten | |
| from keras.layers.convolutional import Convolution2D, MaxPooling2D |
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 "random.hpp" | |
| #define N 10 | |
| int main( void ) | |
| { | |
| float a[N]; | |
| float alpha = 2; | |
| float beta = 3; |
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> | |
| #define N 10 | |
| #define kNumBlockThreads 512 | |
| // copied from random.hpp | |
| #define CUDA_GRID_STRIDE_LOOP(i, n) \ | |
| for (int i = blockIdx.x * blockDim.x + threadIdx.x; \ | |
| i < n; \ | |
| i += blockDim.x * gridDim.x) |