坑1:
1 2 3 4 5 6 7 8 9 10 11 |
$ python main.py /home/ly/anaconda3/envs/learning/lib/python3.6/site-packages/h5py/__init__.py:36: FutureWarning: Conversion of the second argument of issubdtype from `float` to `np.floating` is deprecated. In future, it will be treated as `np.float64 == np.dtype(float).type`. from ._conv import register_converters as _register_converters Traceback (most recent call last): File "/home/ly/anaconda3/envs/learning/lib/python3.6/site-packages/absl/flags/_flag.py", line 166, in _parse return self.parser.parse(argument) File "/home/ly/anaconda3/envs/learning/lib/python3.6/site-packages/absl/flags/_argument_parser.py", line 152, in parse val = self.convert(argument) File "/home/ly/anaconda3/envs/learning/lib/python3.6/site-packages/absl/flags/_argument_parser.py", line 268, in convert type(argument))) TypeError: Expect argument to be a string or int, found <class 'float'> |
解决办法:
在main.py中把
1 |
flags.DEFINE_integer("train_size", np.inf, "The size of train images [np.inf]") |
修改为
1 |
flags.DEFINE_float("train_size", np.inf, "The size of train images [np.inf]") |
坑2:
1 |
TypeError: sigmoid_cross_entropy_with_logits() got an unexpected keyword argument 'targets' |
出错原因:在tensorflow0.12+的版本中tf.nn.sigmoid_cross_entropy_with_logits
方法的targets变更为labels
1 2 3 |
self.g_loss = tf.reduce_mean( tf.nn.sigmoid_cross_entropy_with_logits( logits=self.D_logits_, targets=tf.ones_like(self.D_))) |
修改为
1 2 3 |
self.g_loss = tf.reduce_mean( tf.nn.sigmoid_cross_entropy_with_logits( logits=self.D_logits_, labels=tf.ones_like(self.D_))) |
RUN起来
输入命令,在这里我要训练的图片放在faces_文件夹下,是一个有5W张人脸的jpg数据集
1 |
python main.py --image_size 96 --output_size 48 --dataset faces_ --is_crop True --is_train True --epoch 300 --input_fname_pattern "*.jpg" |
即可开始训练