mnist_softmax.py 文件源码

python
阅读 37 收藏 0 点赞 0 评论 0

项目:photinia 作者: XoriieInpottn 项目源码 文件源码
def main(flags):
    # ???????
    ds = DataSource(flags.directory)
    # tensorflow ??
    config = tf.ConfigProto()
    config.gpu_options.allow_growth = True
    # ??session
    with tf.Session(config=config) as session:
        # ??????
        model = Model('Model', session, flags.input_size, flags.num_classes).build()
        # ??slot
        train = model.get_slot('train')
        predict = model.get_slot('predict')
        # ?????
        session.run(tf.global_variables_initializer())
        # ????
        for i in range(1, flags.nloop + 1):
            # ????batch???
            images_batch, labels_batch = ds.next_batch(flags.bsize)
            # ?????????
            loss = train(images_batch, labels_batch)
            print('Loop {}:\tloss= {}'.format(i, loss))
        # ????????accuracy
        accuracy = predict(ds.test_images, ds.test_labels)
        print('Accuracy on test set: {}'.format(accuracy))
    return 0
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号