tf.reshape()

#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Sat Mar 24 16:35:11 2018

@author: luogan
"""

'''
from tensorflow.examples.tutorials.mnist import input_data

mnist=input_data.read_data_sets('MNIST_data/',one_hot=True)
'''

print(mnist.train.images.shape)

print(mnist.train.labels.shape)

print(mnist.test.images.shape)

print(mnist.test.images.shape)

a=mnist.train.images[8]
#a.reshape(28,28)
import pandas as pd
#b=pd.DataFrame(a)
#b
b=pd.DataFrame(a.reshape(28,28))
#b
#b=pd.DataFrame(a.reshape(28,28))
b.to_excel('c.xls')
d=mnist.train.labels[8]


print(mnist.validation.images.shape)
print(mnist.validation.labels.shape)

import tensorflow as tf

#c=mnist.train.images[:50]

batch=mnist.train.next_batch(50)

c=batch[0]
c=tf.reshape(c,[-1,28,28,1])

#c=mnist.train.next_batch(50)
#发起会话
sess = tf.Session()
#两行都可以执行 具体意思见下方注释
A = tf.Variable(tf.truncated_normal([1,784],0,1,dtype=tf.float32,seed=3))



d=tf.reshape(A,[-1,28,28,1])

#A = tf.Variable(tf.random_uniform([3,4], 1, 10))
#变量初始化
sess.run(A.initializer)
#输出 
print(sess.run(d))
print(d.get_shape())
posted @ 2022-08-19 22:58  luoganttcc  阅读(4)  评论(0编辑  收藏  举报