
运行python代码时出现的问题
运行python代码时出现的问题
一个双子座的洁宝
这个作者很懒,什么都没留下…
展开
-
运行网络成出现错误:RuntimeError: Error(s) in loading state_dict for ReflectionNetwork:
在服务器上运行网络时出现错误:RuntimeError: Error(s) in loading state_dict for ReflectionNetwork:原来:checkpoint = torch.load("/Pre_train/checkpoint_81_test1.pth.tar",map_location='cuda:0')model.load_state_dict(checkpoint['state_dict'])model.eval()修改后:checkpoint原创 2020-11-16 15:58:13 · 1844 阅读 · 2 评论 -
安装指定版本的tensorflow
安装指定版本的tensorflow比较简单,直接:pip install tensorflow==1.3.0在服务器上安装可以:sudo pip install tensorflow==1.3.0需要注意的是==前后没有空格,若是加空格会报错:ERROR: Invalid requirement: '=='若不想指定版本,可以直接:pip install tensorflow默认最新版本...原创 2020-10-13 08:44:14 · 7445 阅读 · 0 评论 -
AttributeError: ‘function‘ object has no attribute ‘_name_‘
在运行python的下面代码时:def log(func): def wrapper(*args,**kw): print('call %s():'%func._name_) return func(*args,**kw) return wrapper@logdef now(): print('2020-09-08')print(now())报错:AttributeError: 'function' object has no attrib原创 2020-09-08 20:32:49 · 797 阅读 · 0 评论 -
(WaterGAN)AttributeError: module ‘tensorflow._api.v1.compat.v1‘ has no attribute ‘placeholder‘
运行WaterGAN时出现:AttributeError: module 'tensorflow._api.v1.compat.v1' has no attribute 'placeholder'(这里我替换时出现错误,把placeholder->placeholderr,所以一定一定要细心细心细心)将import tensorflow as tf 改为import tensorflow.compat.v1 as tf...原创 2020-08-04 12:05:39 · 3036 阅读 · 0 评论 -
(WaterGAN)tf.summary.scalar->tf.compat.v1.summary.scalar
在运行WaterGAN的代码时:将 self.d_loss_sum = tf.summary.scalar("d_loss", self.d_loss) self.d_loss_sum = tf.compat.v1.summary.scalar("d_loss", self.d_loss) 即把tf.summary.scalar->tf.compat.v1.summary.scalar原创 2020-08-03 21:49:34 · 675 阅读 · 1 评论 -
(WaterGAN)AttributeError: module ‘tensorflow‘ has no attribute ‘mul‘
在运行WaterGAN的代码时出现:AttributeError: module 'tensorflow' has no attribute 'mul'将 eta_d = tf.exp(tf.mul(-1.0,tf.multiply(depth,eta))) 改为: eta_d = tf.exp(tf.multiply(-1.0,tf.multiply(depth,eta))) 即改:mul->multiply原创 2020-08-03 20:59:39 · 274 阅读 · 1 评论 -
(WaterGAN)AttributeError: module ‘tensorflow‘ has no attribute ‘pack‘
在运行WaterGAN代码时出现:AttributeError: module 'tensorflow' has no attribute 'pack'将eta = tf.pack([eta_r,eta_g,eta_b],axis=3) 改为: eta = tf.stack([eta_r,eta_g,eta_b],axis=3) 即把将所有pack->stack原创 2020-08-03 20:39:35 · 402 阅读 · 0 评论 -
(WaterGAN)TypeError: Expect argument to be a string or int, found <class ‘float‘>
运行WaterGAN出现错误:TypeError: Expect argument to be a string or int, found <class 'float'>将mainmhl.py中:flags.DEFINE_integer("train_size", np.inf, "The size of train images [np.inf]")改成:flags.DEFINE_float("train_size", np.inf, "The size of train i原创 2020-08-03 20:35:06 · 1313 阅读 · 2 评论 -
AttributeError: module ‘tensorflow‘ has no attribute ‘ConfigProto‘
在运行ARCNN的代码的时候,报错config = tf.compat.v1.ConfigProto()将dataset.py中:#config = tf.ConfigProto() 修改为:config = tf.compat.v1.ConfigProto()原创 2020-07-25 21:33:13 · 757 阅读 · 0 评论 -
Pytorch使用CPU运行“Torch not compiled with CUDA enabled”(电脑无cuda的情况下)
错误提示:Torch not compiled with CUDA enabled修改:1.将torch.cuda.set_device(0)换成device = ('cuda' if torch.cuda.is_available() else 'cpu')2.将checkpoint = torch.load("/home/model/model_J18.pth.tar")换成:checkpoint = torch.load("C:/Users/user/Desktop/CoR原创 2020-07-15 13:37:45 · 11596 阅读 · 3 评论 -
ImportError: cannot import name ‘imread‘
错误提示:from scipy.ndimage import imread ImportError: cannot import name 'imread'改正:from matplotlib.pyplot import imread原创 2020-07-13 21:59:02 · 441 阅读 · 0 评论 -
anaconda下安装sklearn
Pycharm下运行出现错误提示:ModuleNotFoundError: No module named 'sklearn'解决方法:1.打开 anaconda prompt ;2.输入:>activate tensorflow>pip install sklearn问题解决原创 2020-06-16 21:50:58 · 8546 阅读 · 1 评论