1.keras报错
Please use `rate` instead of `keep_prob`. Rate should be set to `rate = 1 - keep_prob`.
解决办法:将tensorflow版本由1.14.0降为1.5.0后,问题解决。
2.ImageDataGenerator.flow_from_directory()的使用
train_mask_gen=train_img_datagen.flow_from_directory('../data/GlaS/labels/',
classes=['train'])
#classes中的值为文件夹名,包含所有训练标签(图片格式任意,我的是.bmp)
3. keras报错---需要转化为tensor
ValueError: Layer deeplabv3plus was called with an input that isn't a symbolic tensor. Received type: <class 'numpy.ndarray'>. Full input: [array([[[[.....]]]])]
这个是因为测试的时候要写output = model.predict(input) .....用多了pytorch,没适应过来
如果用prdict,后期要搭配np.argmax(output,axis=3)
如果用predict_classes则不用
4. keras不接受numpy.array形式的输入,需要转换一下
from keras import backend as K
input = K.cast_to_floatx(input)
input = (B,H,W,C) 跟 pytorch有点差别
5.GPU报错
tensorflow.python.framework.errors_impl.UnknownError: 2 root error(s) found.
(0) Unknown: Failed to get convolution algorithm. This is probably because cuDNN failed to initialize, so try looking to see if a warning log message was printed above.
[[{{node entry_flow_conv1_1/convolution}}]]
[[loss/mul/_6781]]
(1) Unknown: Failed to get convolution algorithm. This is probably because cuDNN failed to initialize, so try looking to see if a warning log message was printed above.
[[{{node entry_flow_conv1_1/convolution}}]]
0 successful operations.
0 derived errors ignored.
我是在keras中遇到的,不知道是什么原因导致的
解决办法抄了别人的,加在要运行的文件头部,代码如下:
from tensorflow.compat.v1 import ConfigProto
from tensorflow.compat.v1 import InteractiveSession
config = ConfigProto()
config.gpu_options.allow_growth = True
session = InteractiveSession(config=config)
5. 没有past模块
ImportError: No module named 'past'
解决办法:pip install future
6. 同时打乱两个数组且不打乱对应关系
a = np.arange(0, 10, 1)
b = np.arange(10, 20, 1)
print(a, b)
# result:[0 1 2 3 4 5 6 7 8 9] [10 11 12 13 14 15 16 17 18 19]
state = np.random.get_state()
np.random.shuffle(a)
print(a)
# result:[6 4 5 3 7 2 0 1 8 9]
np.random.set_state(state)
np.random.shuffle(b)
print(b)
# result:[16 14 15 13 17 12 10 11 18 19]