from keras.datasets import cifar10
(x_train, y_train), (x_test, y_test) = cifar10.load_data()
from keras.datasets import cifar100
(x_train, y_train), (x_test, y_test) = cifar100.load_data(label_mode='fine')
from keras.datasets import imdb
(x_train, y_train), (x_test, y_test) = imdb.load_data(path = "imdb.npz",
num_words = None ,
skip_top = 0 ,
maxlen = None ,
seed = 113 ,
start_char = 1 ,
oov_char = 2 ,
index_from = 3 )
from keras.datasets import reuters
(x_train, y_train), (x_test, y_test) = reuters.load_data(path = "reuters.npz",
num_words = None ,
skip_top = 0 ,
maxlen = None ,
test_split = 0.2 ,
seed = 113 ,
start_char = 1 ,
oov_char = 2 ,
index_from = 3 )
word_index = reuters.get_word_index(path="reuters_word_index.json")
from keras.datasets import mnist
(x_train, y_train), (x_test, y_test) = mnist.load_data()
from keras.datasets import fashion_mnist
(x_train, y_train), (x_test, y_test) = fashion_mnist.load_data()
from keras.datasets import boston_housing
(x_train, y_train), (x_test, y_test) = boston_housing.load_data()
Reference: https://keras.io/datasets/
TensorFlow Trivia
Thursday, 15 August 2019
Keras Datasets
Thursday, 17 January 2019
Deep Learning Hello World Program
###############################################################################
## The DL (Deep Learning) Hello World Program
## References:
## https://www.tensorflow.org/tutorials/
## https://medium.com/the-andela-way/deep-learning-hello-world-e1fc53ea888
###############################################################################
import tensorflow as tf
from keras.datasets import mnist
(x_train, y_train),(x_test, y_test) = mnist.load_data()
x_train, x_test = x_train / 255.0, x_test / 255.0
model = tf.keras.models.Sequential([
tf.keras.layers.Flatten( ),
tf.keras.layers.Dense (512 , activation = tf.nn.relu ),
tf.keras.layers.Dropout(0.2 ),
tf.keras.layers.Dense (10 , activation = tf.nn.softmax)
])
model.compile(optimizer = 'adam' ,
loss = 'sparse_categorical_crossentropy',
metrics = ['accuracy'] )
model.fit(x_train, y_train, epochs=5)
model.evaluate(x_test, y_test)
###############################################################################
# Output
###############################################################################
# Using TensorFlow backend.
# Downloading data from https://s3.amazonaws.com/img-datasets/mnist.npz
# 11493376/11490434 [==============================] - 1s 0us/step
# Epoch 1/5
# 60000/60000 [==============================] - 14s 236us/step - loss: 0.2027 - acc: 0.9406
# Epoch 2/5
# 60000/60000 [==============================] - 14s 225us/step - loss: 0.0805 - acc: 0.9756
# Epoch 3/5
# 60000/60000 [==============================] - 13s 222us/step - loss: 0.0517 - acc: 0.9839
# Epoch 4/5
# 60000/60000 [==============================] - 14s 227us/step - loss: 0.0370 - acc: 0.9883
# Epoch 5/5
# 60000/60000 [==============================] - 13s 224us/step - loss: 0.0262 - acc: 0.9917
# 10000/10000 [==============================] - 1s 51us/step
# [0.07304962697861483, 0.9789]
Wednesday, 16 January 2019
TensorFlow Keras Models
compile(optimizer ,
loss = None,
metrics = None,
loss_weights = None,
sample_weight_mode = None,
weighted_metrics = None,
target_tensors = None)
fit(x = None,
y = None,
batch_size = None,
epochs = 1 ,
verbose = 1 ,
callbacks = None,
validation_split = 0.0 ,
validation_data = None,
shuffle = True,
class_weight = None,
sample_weight = None,
initial_epoch = 0 ,
steps_per_epoch = None,
validation_steps = None)
evaluate(x = None,
y = None,
batch_size = None,
verbose = 1 ,
sample_weight = None,
steps = None)
predict(x,
batch_size = None,
verbose = 0 ,
steps = None)
train_on_batch(x, y, sample_weight=None, class_weight=None)
test_on_batch (x, y, sample_weight=None)
predict_on_batch(x)
fit_generator(generator ,
steps_per_epoch = None ,
epochs = 1 ,
verbose = 1 ,
callbacks = None ,
validation_data = None ,
validation_steps = None ,
class_weight = None ,
max_queue_size = 10 ,
workers = 1 ,
use_multiprocessing = False,
shuffle = True ,
initial_epoch = 0 )
evaluate_generator(generator ,
steps = None ,
max_queue_size = 10 ,
workers = 1 ,
use_multiprocessing = False,
verbose = 0 )
predict_generator(generator ,
steps = None ,
max_queue_size = 10 ,
workers = 1 ,
use_multiprocessing = False,
verbose = 0 )
get_layer(name=None, index=None)
Reference: keras.io
TensorFlow Keras Constraints
keras.constraints.MaxNorm(max_value=2, axis=0)
keras.constraints.NonNeg()
keras.constraints.UnitNorm(axis=0)
keras.constraints.MinMaxNorm(min_value=0.0, max_value=1.0, rate=1.0, axis=0)
Reference: keras.io
TensorFlow Keras Regulizers
keras.regularizers.l1 (0.)
keras.regularizers.l2 (0.)
keras.regularizers.l1_l2(l1 = 0.01, l2 = 0.01)
Reference: keras.io
TensorFlow Keras Initializers
keras.initializers.Initializer()
keras.initializers.Zeros()
keras.initializers.Ones()
keras.initializers.Constant(value=0)
keras.initializers.RandomNormal (mean = 0.0 , stddev = 0.05, seed = None)
keras.initializers.RandomUniform (minval = -0.05, maxval = 0.05, seed = None)
keras.initializers.TruncatedNormal(mean = 0.0 , stddev = 0.05, seed = None)
keras.initializers.VarianceScaling(scale = 1.0 ,
mode = 'fan_in',
distribution = 'normal',
seed = None )
keras.initializers.Orthogonal(gain=1.0, seed=None)
keras.initializers.Identity (gain=1.0)
keras.initializers.lecun_uniform (seed=None)
keras.initializers.glorot_normal (seed=None)
keras.initializers.glorot_uniform(seed=None)
keras.initializers.he_normal (seed=None)
keras.initializers.lecun_normal (seed=None)
keras.initializers.he_uniform (seed=None)
Reference: keras.io
TensorFlow Keras Applications
keras.applications.xception.Xception(include_top = True ,
weights = 'imagenet',
input_tensor = None ,
input_shape = None ,
pooling = None ,
classes = 1000 )
keras.applications.vgg16.VGG16(include_top = True ,
weights = 'imagenet',
input_tensor = None ,
input_shape = None ,
pooling = None ,
classes = 1000 )
keras.applications.vgg19.VGG19(include_top = True ,
weights = 'imagenet',
input_tensor = None ,
input_shape = None ,
pooling = None ,
classes = 1000 )
keras.applications.resnet50.ResNet50(include_top = True ,
weights = 'imagenet',
input_tensor = None ,
input_shape = None ,
pooling = None ,
classes = 1000 )
keras.applications.inception_v3.InceptionV3(include_top = True ,
weights = 'imagenet',
input_tensor = None ,
input_shape = None ,
pooling = None ,
classes = 1000 )
keras.applications.inception_resnet_v2.InceptionResNetV2(include_top = True ,
weights = 'imagenet',
input_tensor = None ,
input_shape = None ,
pooling = None ,
classes = 1000 )
keras.applications.mobilenet.MobileNet(input_shape = None,
alpha = 1.0,
depth_multiplier = 1,
dropout = 1e-3,
include_top = True,
weights = 'imagenet',
input_tensor = None,
pooling = None,
classes = 1000)
keras.applications.densenet.DenseNet121(include_top = True ,
weights = 'imagenet',
input_tensor = None ,
input_shape = None ,
pooling = None ,
classes = 1000 )
keras.applications.densenet.DenseNet169(include_top = True ,
weights = 'imagenet',
input_tensor = None ,
input_shape = None ,
pooling = None ,
classes = 1000 )
keras.applications.densenet.DenseNet201(include_top = True ,
weights = 'imagenet',
input_tensor = None ,
input_shape = None ,
pooling = None ,
classes = 1000 )
keras.applications.nasnet.NASNetLarge(input_shape = None ,
include_top = True ,
weights = 'imagenet',
input_tensor = None ,
pooling = None ,
classes = 1000 )
keras.applications.nasnet.NASNetMobile(input_shape = None ,
include_top = True ,
weights = 'imagenet',
input_tensor = None ,
pooling = None ,
classes = 1000 )
keras.applications.mobilenet_v2.MobileNetV2(input_shape = None ,
alpha = 1.0 ,
depth_multiplier = 1 ,
include_top = True ,
weights = 'imagenet',
input_tensor = None ,
pooling = None ,
classes = 1000 )
Reference: keras.io
Subscribe to:
Posts (Atom)