- Python 3
- Pip 3
$ brew install python3
import keras.backend as K | |
import tensorflow as tf | |
class Model: | |
def __init__(self,batch_size): | |
self.batch_size = batch_size | |
def loss_DSSIS_tf11(self, y_true, y_pred): | |
"""Need tf0.11rc to work""" | |
y_true = tf.reshape(y_true, [self.batch_size] + get_shape(y_pred)[1:]) | |
y_pred = tf.reshape(y_pred, [self.batch_size] + get_shape(y_pred)[1:]) |
""" | |
When traing ML models on text we usually need to represent words/character in one-hot encoding. | |
This can be done in preprocessing, however it may make the dataset file bigger. Also when we'd | |
like to use an Embedding layer, it accepts the original integer indexes instead of one-hot codes. | |
Can be move the one-hot encoding from pre-preprocessing directly into the model? | |
If so we could choose from two options: use one-hot inputs or perform embedding. | |
A way how to do this was suggested in Keras issue [#3680](https://github.com/fchollet/keras/issues/3680). |
from keras import layers | |
def residual_block(y, nb_channels, _strides=(1, 1), _project_shortcut=False): | |
shortcut = y | |
# down-sampling is performed with a stride of 2 | |
y = layers.Conv2D(nb_channels, kernel_size=(3, 3), strides=_strides, padding='same')(y) | |
y = layers.BatchNormalization()(y) | |
y = layers.LeakyReLU()(y) |
import numpy as np | |
from numpy import pi | |
# import matplotlib.pyplot as plt | |
N = 400 | |
theta = np.sqrt(np.random.rand(N))*2*pi # np.linspace(0,2*pi,100) | |
r_a = 2*theta + pi | |
data_a = np.array([np.cos(theta)*r_a, np.sin(theta)*r_a]).T | |
x_a = data_a + np.random.randn(N,2) |
import numpy as np | |
from keras import backend as K | |
from keras.legacy import interfaces | |
import keras | |
from keras.layers import Layer, InputLayer, Input | |
import tensorflow as tf | |
from keras.engine.topology import Node | |
from keras.utils import conv_utils | |
For better understanding we will use the following naming convention:
[ L1 ][ L2 ][ L3 ][ Space ][ R1 ][ R2 ][ R3 ]
import random | |
from itertools import chain, cycle, islice | |
import torch.utils.data as data | |
import matplotlib.pyplot as plt | |
from matplotlib.patches import Rectangle | |
import time | |
import torch | |
import numpy as np |