Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

mnist

import tflearn
from tflearn.layers.conv import conv_2d, max_pool_2d
from tflearn.layers.core import input_data, dropout, fully_connected
from tflearn.layers.estimator import regression
import tflearn.datasets.mnist as mnist

X, Y, test_x, test_y = mnist.load_data(one_hot=True)

X = X.reshape([-1, 28, 28, 1])
test_x = test_x.reshape([-1, 28, 28, 1])

convnet = input_data(shape=[None, 28, 28, 1], name='input')

convnet = conv_2d(convnet, 32, 2, activation='relu')
convnet = max_pool_2d(convnet, 2)

convnet = conv_2d(convnet, 64, 2, activation='relu')
convnet = max_pool_2d(convnet, 2)

convnet = fully_connected(convnet, 1024, activation='relu')
convnet = dropout(convnet, 0.8)

convnet = fully_connected(convnet, 10, activation='softmax')
convnet = regression(convnet, optimizer='adam', learning_rate=0.01, loss='categorical_crossentropy', name='targets')

model = tflearn.DNN(convnet)
model.fit({'input': X}, {'targets': Y}, n_epoch=10, validation_set=({'input': test_x}, {'targets': test_y}), 
    snapshot_step=500, show_metric=True, run_id='mnist')
Comment

PREVIOUS NEXT
Code Example
Python :: pytesseract restrict char 
Python :: Failed to build wxPython 
Python :: create contract from interface in brownie 
Python :: Flatten List in Python Using NumPy concatenate 
Python :: import open3d Illegal instruction (core dumped) 
Python :: torch distributed address already in use 
Python :: function for permutation sampling 
Python :: python email subject decode 
Python :: Code Example of Hashmap in Python 
Python :: how to print list without newline 
Python :: what is not equals in python 
Python :: unpersist cache pyspark 
Python :: Average of total in django querysets 
Python :: every substring python 
Python :: how to remove axis in matplotlib 
Python :: list of list to numpy array 
Python :: pandas sequential numbering within group 
Python :: split custom pytorch dataset 
Python :: python oneline if statement 
Python :: scipy.optimize.curve_fit 3D 
Python :: python manually trigger exception 
Python :: getch backspace pytohn 
Python :: convert math equation from string to int 
Python :: add last item of array at the first index of the array python 
Python :: python listas por comprension 
Python :: python order list by multiple index 
Python :: how to format a file in python 
Python :: update matplotlib params 
Python :: # convert string to date 
Python :: sort decreasing python 
ADD CONTENT
Topic
Content
Source link
Name
7+6 =