Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

tensorflow

import tensorflow as tf

mnist = tf.keras.datasets.mnist

(xTrain, yTrain), (xTest, yTest) = mnist.load_data()

xTrain, xTest = xTrain / 255, xTest / 255

network = tf.keras.models.Sequential([
  tf.keras.layers.Flatten(input_shape=(28, 28)),
  tf.keras.layers.Dense(128, activation='relu'),
  tf.keras.layers.Dense(10, activation="sigmoid")
])

predictions = network(xTrain[:1]).numpy()

loss = tf.keras.losses.SparseCategoricalCrossentropy(from_logits=True)

loss(yTrain[:1], predictions).numpy()

network.compile("adam", loss, ["accuracy"])

network.fit(xTrain, yTrain, epochs=5)

network.evaluate(xTest, yTest, verbose=2)
Comment

PREVIOUS NEXT
Code Example
Python :: add legend to colorbar 
Python :: pandas pivot tables 
Python :: check if string is python code 
Python :: change value in tuple 
Python :: Tree Traversals inorder,preorder and postorder 
Python :: discord bot python 
Python :: google.protobuf.Struct example python 
Python :: python count appearances in list 
Python :: django button 
Python :: command for python shell 
Python :: longest common prefix 
Python :: how to split a string by colon in python 
Python :: numpy.sort 
Python :: join multiple excel files with python 
Python :: matplotlib window size 
Python :: python add list 
Python :: django forms 
Python :: python string: .strip() 
Python :: how to limit a command to a role in discord.py 
Python :: delete multiple dataframes at once in python 
Python :: pairs with specific difference 
Python :: python turtle tutorial 
Python :: Set .difference() Operation in python3 
Python :: django password hashers 
Python :: Routes In Django 
Python :: pdf to word 
Python :: catching exceptions in python 
Python :: densenet python keras 
Python :: how to use python all() function to check a list is empty or not 
Python :: if queryset is empty django 
ADD CONTENT
Topic
Content
Source link
Name
7+5 =