The following error is mainly due to TensorFlow Upgrade 1.0 after the incompatibility with the previous code.
1. Attributeerror: ' Module ' object has Noattribute ' Random_crop '
Solution:
Change distorted_image= Tf.image.random_crop (reshaped_image, [height, Width]) to:
Distorted_image = Tf.random_crop (Reshaped_image,[height, width,3])
2. Attributeerror: ' Module ' object has no attribute ' Summarywriter '
Solution:
Tf.train.SummaryWriter instead of: tf.summary.FileWriter
3. Attributeerror: ' Module ' object has no attribute ' summaries '
Solution:
Tf.merge_all_summaries () instead: Summary_op =tf.summaries.merge_all ()
4. Attributeerror: ' Module ' object hasno attribute ' Histogram_summary '
Tf.histogram_summary (Var.op.name,var) instead: Tf.summaries.histogram ()
5. Attributeerror: ' Module ' object hasno attribute ' Scalar_summary '
Tf.scalar_summary (l.op.name+ ' (raw) ', L)
Solution:
Tf.scalar_summary (' images ', images) changed to: Tf.summary.scalar (' images ', images)
Tf.image_summary (' images ', images) changed to: Tf.summary.image (' images ', images)
6. Valueerror:only call ' softmax_cross_entropy_with_logits ' withnamed arguments (labels= ..., logits= ...)
Solution:
Cifar10.loss (labels, logits) instead: Cifar10.loss (logits=logits,labels=labels)
Cross_entropy= Tf.nn.softmax_cross_entropy_with_logits (
Logits, dense_labels,name= ' cross_entropy_per_example ')
Switch
Cross_entropy = Tf.nn.softmax_cross_entropy_with_logits (
Logits=logits, labels=dense_labels,name= ' cross_entropy_per_example ')
7. Typeerror:using a ' tf. Tensor ' as a Python ' bool ' isnot allowed. Use ' If T isn't None: ' instead of ' if T: ' to test if a tensor isdefined, and use TensorFlow ops such as Tf.cond to Execut e subgraphsconditioned on the value of a tensor.
Solution:
If grad: Change to If Grad is not None:
8. Valueerror:shapes (2, 1) and () are incompatible
Solution:
concated = Tf.concat (1, [Indices, Sparse_labels]) instead:
concated= Tf.concat ([Indices, Sparse_labels], 1)
9. Error:
File "/home/lily/work/tensorflow/cirfar-10/tensorflow.cifar10-master/cifar10_input.py", line, in Read_cifar10
Result.key, Value =reader.read (filename_queue)
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/ops/io_ops.py", line 326, in read
Queue_ref = Queue.queue_ref
Attributeerror: ' str ' object Hasno attribute ' Queue_ref '
Solution:
Since the path of the training sample needs to be modified, assign the Data_dir in cifar10_input.py to the folder where the local data resides.
Attributeerror: ' Module ' object has no attribute ' Summarywriter '
Tf.train.SummaryWriter instead of: tf.summary.FileWriter
Attributeerror: ' Module ' object has no attribute ' summaries '
Tf.merge_all_summaries () instead: Summary_op = Tf.summaries.merge_all ()
Tf.histogram_summary (Var.op.name, Var)
Attributeerror: ' Module ' object has no attribute ' histogram_summary '
Instead: Tf.summaries.histogram ()
Tf.scalar_summary (L.op.name + ' (raw) ', L)
Attributeerror: ' Module ' object has no attribute ' scalar_summary '
Tf.scalar_summary (' images ', images) changed to: Tf.summary.scalar (' images ', images)
Tf.image_summary (' images ', images) changed to: Tf.summary.image (' images ', images)
Valueerror:only call ' Softmax_cross_entropy_with_logits ' with named arguments (labels= ..., logits= ...)
Cifar10.loss (labels, logits) instead: Cifar10.loss (logits=logits, Labels=labels)
Cross_entropy = Tf.nn.softmax_cross_entropy_with_logits (
Logits, Dense_labels, name= ' cross_entropy_per_example ')
Switch
Cross_entropy = Tf.nn.softmax_cross_entropy_with_logits (
Logits=logits, Labels=dense_labels, name= ' cross_entropy_per_example ')
Typeerror:using a ' tf. Tensor ' as a Python ' bool ' is not allowed. Use ' If T isn't ' None: ' instead of ' if T: ' to test if a tensor are defined, and use TensorFlow ops such as Tf.cond to Execu Te subgraphs conditioned on the value of a tensor.
If grad: Change to If Grad is not None:
Valueerror:shapes (2, 1) and () are incompatible
concated = Tf.concat (1, [Indices, Sparse_labels]) instead:
concated = Tf.concat ([indices, Sparse_labels], 1)
tensorflow1.0
Major API improvements
The Busadjacency enumeration is replaced by the protocol buffer devicelocality. The bus index now starts at 1 instead of 0, and at the same time, uses bus_id==0, previously bus_any.
Env::fileexists and filesystem::fileexists now return tensorflow::status instead of a bool. Any caller of this function can convert the return to bool by adding. OK () to the call.
The C api:tf_sessionwithgraph type is renamed Tf_session, which is preferred in the binding language of TensorFlow. The original tf_session has been renamed to Tf_deprecatedsession.
C Api:tf_port was renamed to Tf_output.
C API: The caller retains ownership of the Tf_tensor objects provided to Tf_run, Tf_sessionrun, Tf_setattrtensor, and so on.
Rename tf.image.per_image_whitening () to Tf.image.per_image_standardization ().
Moved the Summary Protobuf constructor to the Tf.summary sub-module.
Histogram_summary, Audio_summary, Scalar_summary,image_summary, Merge_summary, and merge_all_summaries are no longer used.
Combine Batch_ * and regular versions of linear algebra and FFT operations. The general operation now also handles batching. All Batch_ * Python interfaces have been removed.
TF.ALL_VARIABLES,TF. VARIABLES and Tf.initialize_all_variables were renamed TF.GLOBAL_VARIABLES,TF. Global_variables and Tf.global_variable_initializers respectively.