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
/******************************************************************************* | |
Copyright (c) 2015 Thomas Telkamp and Matthijs Kooijman | |
Permission is hereby granted, free of charge, to anyone | |
obtaining a copy of this document and accompanying files, | |
to do whatever they want with them without any restriction, | |
including, but not limited to, copying, modification and redistribution. | |
NO WARRANTY OF ANY KIND IS PROVIDED. | |
This example sends a valid LoRaWAN packet with payload "Hello, |
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["CUDA_VISIBLE_DEVICES"]="1" #Before all | |
import tensorflow as tf | |
config = tf.ConfigProto() | |
config.gpu_options.allow_growth = True # Use only necessary memory | |
#config.gpu_options.per_process_gpu_memory_fraction = 0.5 | |
session = tf.Session(config=config) # Before importing Keras! |
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
#!/usr/bin/python3 | |
import numpy as np | |
import sys | |
import time | |
import math | |
import os | |
def plot(array, width, height): | |
size = len(array) | |
y = [array[int(round(k*size/width)):int(round((k+1)*size/width))] for k in range(width)] |
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 plot(array, width, height): | |
size = len(array) | |
y = [array[int(round(k*size/width)):int(round((k+1)*size/width))] for k in range(width)] | |
y = [np.mean(k) for k in y[5:]] #y[5:] when the firsts values are too big | |
y = height*(y-np.min(y))/(np.max(y)-np.min(y)) | |
res = np.array(list([list('#'*int(round(y[k]))+' '*int(round(height-y[k]))) for k in range(len(y))])) | |
res = np.rot90(res, k=1, axes=(0,1)) | |
for r in res: | |
print(''.join(r)) |
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
# Launch tensorboard | |
# $ tensorboard --logdir=~/tensorboard.log | |
import tensorflow as tf | |
from keras.layers import Dense, Dropout, Conv3D, MaxPooling3D, GlobalAveragePooling3D | |
from keras.models import Sequential | |
import keras.backend as K | |
model = Sequential() | |
model.add(Conv3D(8, kernel_size=(3, 3, 3), input_shape=(None,None,None,1), padding='same')) |
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 keras import backend as K | |
from keras.engine.base_layer import Layer, InputSpec | |
from keras import activations | |
from keras.layers.convolutional import _Conv | |
import numpy as np | |
class TDNN(_Conv): | |
# Original TDNN | |
# A. Waibel, T. Hanazawa, G. Hinton, K. Shikano and K. J. Lang, | |
# "Phoneme recognition using time-delay neural networks," |
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
/******************************************************************************* | |
* Copyright (c) 2015 Thomas Telkamp and Matthijs Kooijman | |
* | |
* Permission is hereby granted, free of charge, to anyone | |
* obtaining a copy of this document and accompanying files, | |
* to do whatever they want with them without any restriction, | |
* including, but not limited to, copying, modification and redistribution. | |
* NO WARRANTY OF ANY KIND IS PROVIDED. | |
* | |
* This example sends a valid LoRaWAN packet with payload "Hello, |
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 numpy as np | |
from collections.abc import Iterable | |
import copy | |
# Find the number of dimensions in a nested list | |
def find_n_dim(array, depth=0): | |
if isinstance(array, Iterable): | |
if len(array)==0: | |
return depth | |
return max([find_n_dim(e, depth+1) for e in array]) |