Skip to main content

based on tensorflow

Project description

some simple functions based on tensorflow

#####################
Simple Example here

#####################
import tensorflow as tf
from yfml.layers import *
from yfml.train import *
from yfml.utils import *
from yfml.quick_build import *
from tensorflow.examples.tutorials.mnist import input_data


mnist = input_data.read_data_sets('MNIST_data', one_hot=True)
train_data, train_label = mnist.train.next_batch(50000)
training_data = Data(train_data, train_label)
x = fl_holder([None, 784])
y = fl_holder([None, 10])
if_training = bool_holder()
x_ = reshape(x, [-1, 28, 28, 1])
final = mix_stack('stack', x_, types=['conv2d', 'maxpool2d', 'conv2d', 'maxpool2d', 'fc', 'fc'],
shapes=[16, 2, 32, 2, 256, 10], use_batch_norm=False, if_training=if_training,
activation_fn='relu', last_activation_fn='softmax')
loss = loss_fn(final, y)
opt = optimize(loss, 0.001, optimizer='adam', regularizer=['l2', 0.001])
accuracy = compute_accuracy(final, y)
sess = tf.Session()
sess.run(tf.global_variables_initializer())
for i in range(1000):
training_data.shuffle()
iter = 50000//100
avg_acc = 0.
for j in range(iter):
xs, ys = training_data.next_batch(100)
acc, _ = sess.run([accuracy, opt], {x: xs, y: ys, if_training:True})
avg_acc += acc/iter
print('accuracy is : ', avg_acc)


Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

yfml-0.1.0-py2.py3-none-any.whl (7.2 kB view details)

Uploaded Python 2Python 3

File details

Details for the file yfml-0.1.0-py2.py3-none-any.whl.

File metadata

  • Download URL: yfml-0.1.0-py2.py3-none-any.whl
  • Upload date:
  • Size: 7.2 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/38.2.3 requests-toolbelt/0.8.0 tqdm/4.29.1 CPython/3.5.2

File hashes

Hashes for yfml-0.1.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 d6c8435e6cbc27829f0607d110d0e91335a312f345d01b14d7fe49d07a8f2fae
MD5 606a57262011edd5c2ab70f16b8cbd8f
BLAKE2b-256 fa33128db148a74270948aebbf892d57c40d55f1410476b145f995f31c594c97

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page