1.grammary系列函數修改
- tf.histogram_summary() 和 tf.contrib.deprecated.histogram_summary() 修改為 tf.summary.histogram()
- tf.scalar_summary() 和 tf.contrib.deprecated.scalar_summary() 修改為 tf.summary.scalar()
- tf.image_summary() 修改為 tf.summary.image()
- tf.merge_summary() 修改為 tf.summary.merge()
- tf.merge_all_summaries() 修改為 tf.summary.merge_all()
- tf.train.SummaryWriter 修改為 tf.summary.FileWriter()
2.計算函數修改
- tf.sub() 修改為 tf.subtract()
- tf.mul() 修改為 tf.multiply()
- tf.div() 修改為 tf.divide()
- tf.mod() 修改為 tf.truncatemod()
- tf.inv() 修改為 tf.reciprocal()
- tf.list_diff() 修改為 tf.setdiff1d()
- tf.listdiff() 修改為 tf.setdiff1d()
- tf.neg() 修改為 tf.negative()
- tf.select() 修改為 tf.where()
3.定義變量修改
- tf.variables() 修改為 tf.gobal_variables()
- tf.all_variables() 修改為 tf.global_variables()
- tf.initialize_all_variables() 修改為 tf.global_variables_initializer()
- tf.initialize_local_variables() 修改為 tf.local_variables_initializer()
- tf.initialize_variables() 修改為 tf.variables_initializer()
4.函數的參數修改
- tf.nn.softmax_cross_entropy_with_logits(labels, logits)
修改為 tf.nn.softmax_cross_entropy_with_logits(logits=logits,labels=labels)
- .loss(labels, logits) 修改為 .loss(logits=logits,labels=labels)
- tf.concat(concat_dim, values, name='concat')參數:1.concat_dim:一個整數,表示在哪一位度進行連接配接;2.values:是兩個或者一組待連接配接的tensor;改變後的函數為concat(values,axis,name='concat'),很顯然是将前兩個參數掉換了位置。(tf.concat(a,b) 修改為 tf.concat(b,a))
- tf.split(dimension, num_split, input):dimension是切割次元,num_split是切割的數量,input是傳入需要切割的tensor。改變後的函數為tf.split( value, num_or_size_splits, axis=0)
是傳入需要切割的tensor,value
是切割的數量,num_or_size_splits
是切割次元。 是以需要将原來split的參數1和參數3換位置。(tf.split(a,b,c)修改為 tf.split(c,b,a))axis
5.其他修改
- tf.image.random_crop() 修改為 tf.random_crop()
- tf.image.per_image_whitening() 修改為 tf.image.per_image_standardization()
6.TypeError: Using a `tf.Tensor` as a Python `bool` isnot allowed. Use `if t is not None:` instead of `if t:` to test if a tensor isdefined, and use TensorFlow ops such as tf.cond to execute subgraphsconditioned on the value of a tensor.
這裡的原因是tensorflow的tensor不再是可以直接作為bool值來使用了,需要進行判斷。
如:if grad: 改為 if grad is not None:
參考部落格:
https://www.cnblogs.com/cvtoEyes/p/8981994.html
https://blog.csdn.net/xxzhangx/article/details/58005846
https://blog.csdn.net/u010528012/article/details/70860977
https://blog.csdn.net/u010700335/article/details/70885689
https://www.cnblogs.com/Davirain/p/8940080.html
https://blog.csdn.net/SangrealLilith/article/details/80272346