WARNING:tensorflow:From <ipython-input-4-3a92e645b733>:1: read_data_sets (from tensorflow.examples.tutorials.mnist.input_data) is deprecated and will be removed in a future version.
Instructions for updating:
Please use alternatives such as: tensorflow_datasets.load('mnist')
WARNING:tensorflow:From d:\progra~2\python\virtua~1\py37_x64\lib\site-packages\tensorflow_core\examples\tutorials\mnist\input_data.py:297: _maybe_download (from tensorflow.examples.tutorials.mnist.input_data) is deprecated and will be removed in a future version.
Instructions for updating:
Please write your own downloading logic.
WARNING:tensorflow:From d:\progra~2\python\virtua~1\py37_x64\lib\site-packages\tensorflow_core\examples\tutorials\mnist\input_data.py:299: _extract_images (from tensorflow.examples.tutorials.mnist.input_data) is deprecated and will be removed in a future version.
Instructions for updating:
Please use tf.data to implement this functionality.
Extracting data/train-images-idx3-ubyte.gz
WARNING:tensorflow:From d:\progra~2\python\virtua~1\py37_x64\lib\site-packages\tensorflow_core\examples\tutorials\mnist\input_data.py:304: _extract_labels (from tensorflow.examples.tutorials.mnist.input_data) is deprecated and will be removed in a future version.
Instructions for updating:
Please use tf.data to implement this functionality.
Extracting data/train-labels-idx1-ubyte.gz
WARNING:tensorflow:From d:\progra~2\python\virtua~1\py37_x64\lib\site-packages\tensorflow_core\examples\tutorials\mnist\input_data.py:112: _dense_to_one_hot (from tensorflow.examples.tutorials.mnist.input_data) is deprecated and will be removed in a future version.
Instructions for updating:
Please use tf.one_hot on tensors.
Extracting data/t10k-images-idx3-ubyte.gz
Extracting data/t10k-labels-idx1-ubyte.gz
WARNING:tensorflow:From d:\progra~2\python\virtua~1\py37_x64\lib\site-packages\tensorflow_core\examples\tutorials\mnist\input_data.py:328: _DataSet.__init__ (from tensorflow.examples.tutorials.mnist.input_data) is deprecated and will be removed in a future version.
Instructions for updating:
Please use alternatives such as official/mnist/_DataSet.py from tensorflow/models.
MNIST ready
WARNING:tensorflow:From d:\progra~2\python\virtua~1\py37_x64\lib\site-packages\tensorflow_core\python\ops\resource_variable_ops.py:1635: calling BaseResourceVariable.__init__ (from tensorflow.python.ops.resource_variable_ops) with constraint is deprecated and will be removed in a future version.
Instructions for updating:
If using Keras pass *_constraint arguments to layers.
init = tf.compat.v1.global_variables_initializer()
sess = tf.compat.v1.Session()
sess.run(init)
training_epochs =15
batch_size =100
display_step =5for epoch inrange(training_epochs):
avg_cost =0.# total_batch = int(mnist.train.num_examples/batch_size)
total_batch =10# 比较耗时,所以此处指定为10# Loop over all batchesfor i inrange(total_batch):
batch_xs, batch_ys = mnist.train.next_batch(batch_size)# Fit training using batch data
sess.run(optm, feed_dict={x: batch_xs, y: batch_ys, keepratio:0.7})# Compute average loss
avg_cost += sess.run(cost, feed_dict={x: batch_xs, y: batch_ys, keepratio:1.})/total_batch
# Display logs per epoch stepif epoch % display_step ==0:print("Epoch: %03d/%03d cost: %.9f"%(epoch, training_epochs, avg_cost))
train_acc = sess.run(accr, feed_dict={x: batch_xs, y: batch_ys, keepratio:1.})print(" Training accuracy: %.3f"%(train_acc))
test_acc = sess.run(accr, feed_dict={x: testimg, y: testlabel, keepratio:1.})print(" Test accuracy: %.3f"%(test_acc))print("OPTIMIZATION FINISHED")
Epoch: 000/015 cost: nan
Training accuracy: 0.100
Test accuracy: 0.098
Epoch: 005/015 cost: nan
Training accuracy: 0.100
Test accuracy: 0.098
Epoch: 010/015 cost: nan
Training accuracy: 0.080
Test accuracy: 0.098
OPTIMIZATION FINISHED
Test accuracy: 0.098
Epoch: 005/015 cost: nan
Training accuracy: 0.100
Test accuracy: 0.098
Epoch: 010/015 cost: nan
Training accuracy: 0.080
Test accuracy: 0.098
OPTIMIZATION FINISHED
Tensorflow 卷积结构模型Tensorflow 卷积结构模型卷积结构模型AttributeError: module 'tensorflow' has no attribute 'Print'测试案例AttributeError: module 'tensorflow_core._api.v2.train' has no attribute 'AdamOptimizer'Tensorfl...