Spectral-Spatial Residual Network for Hyperspectral Image Classification--SSRN代码执行问题

论文:Spectral-Spatial Residual Network for Hyperspectral Image Classification: A 3-D Deep Learning Framework

代码 SSRN。路径首先修改

然后 写入path2对应的文件内容时候出错。后来修改了modelstatsrecord.py中三个函数中的代码,如黑体显示的部分,改为斜体显示的内容

def outputStats_assess(KAPPA_AE, OA_AE, AA_AE, ELEMENT_ACC_AE, CATEGORY, path1, path2):


    f = open(path1, 'a')

    sentence0 = 'KAPPAs, mean_KAPPA ± std_KAPPA for each iteration are:' + str(KAPPA_AE) + str(np.mean(KAPPA_AE)) + ' ± ' + str(np.std(KAPPA_AE)) + '\n'
    f.write(sentence0)
    sentence1 = 'OAs, mean_OA ± std_OA for each iteration are:' + str(OA_AE) + str(np.mean(OA_AE)) + ' ± ' + str(np.std(OA_AE)) + '\n'
    f.write(sentence1)
    sentence2 = 'AAs, mean_AA ± std_AA for each iteration are:' + str(AA_AE) + str(np.mean(AA_AE)) + ' ± ' + str(np.std(AA_AE)) + '\n'
    f.write(sentence2)

    element_mean = np.mean(ELEMENT_ACC_AE, axis=0)
    element_std = np.std(ELEMENT_ACC_AE, axis=0)
    sentence5 = "Mean of all elements in confusion matrix:" + str(np.mean(ELEMENT_ACC_AE, axis=0)) + '\n'
    f.write(sentence5)
    sentence6 = "Standard deviation of all elements in confusion matrix" + str(np.std(ELEMENT_ACC_AE, axis=0)) + '\n'+ '\n'
    f.write(sentence6)

    f.close()
    '''
    # BELOW IS ERROR 
    print_matrix = np.zeros((CATEGORY), dtype=object)
    for i in range(CATEGORY):
        print_matrix[i] = str(element_mean[i]) + " ± " + str(element_std[i])

    np.savetxt(path2, print_matrix.astype(str), fmt='%s', delimiter="\t",
               newline='\n')
    '''
    #BELOW IS CORRECT 2019.3.13

    f = open(path2, 'a')
    print_matrix = np.zeros((CATEGORY), dtype=object)
    for i in range(CATEGORY):
        print_matrix[i] = str(element_mean[i]) + " ± " + str(element_std[i])+ '\n'+ '\n'
        f.write(print_matrix[i])
    f.close()

2、up_classification_maps.py执行时候的问题:

/home/gis/anaconda3/envs/Pytguo27/bin/python /home/gis/Downloads/pycharm-community-2017.2/helpers/pydev/pydevd.py --multiproc --qt-support=auto --client 127.0.0.1 --port 44567 --file "/home/gis/PycharmProjects/guo/SSRN-master/Classification Maps/UP_classification_maps.py"
Connected to pydev debugger (build 172.3317.103)
pydev debugger: process 1281 is connecting

Using TensorFlow backend.
(610, 340, 103)
/home/gis/.local/lib/python2.7/site-packages/sklearn/utils/validation.py:475: DataConversionWarning: Data with input dtype uint16 was converted to float64 by the scale function.
  warnings.warn(msg, DataConversionWarning)
# 1 Iteration
('input shape:', 103)
('input shape:', (None, 7, 7, 49, 24))
('conv_spc_result shape:', (None, 7, 7, 1, 128))
('conv1 shape:', (None, 5, 5, 1, 24))
('input shape:', (None, 5, 5, 1, 24))
2019-03-13 21:10:06.185106: I tensorflow/core/platform/cpu_feature_guard.cc:137] Your CPU supports instructions that this TensorFlow binary was not compiled to use: SSE4.1 SSE4.2 AVX AVX2 FMA
2019-03-13 21:10:06.259797: I tensorflow/stream_executor/cuda/cuda_gpu_executor.cc:895] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero
2019-03-13 21:10:06.260048: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1105] Found device 0 with properties: 
name: GeForce GTX 1080 Ti major: 6 minor: 1 memoryClockRate(GHz): 1.683
pciBusID: 0000:01:00.0
totalMemory: 10.92GiB freeMemory: 10.76GiB
2019-03-13 21:10:06.260059: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1195] Creating TensorFlow device (/device:GPU:0) -> (device: 0, name: GeForce GTX 1080 Ti, pci bus id: 0000:01:00.0, compute capability: 6.1)
Backend TkAgg is interactive backend. Turning interactive mode on.
Traceback (most recent call last):
  File "/home/gis/Downloads/pycharm-community-2017.2/helpers/pydev/pydevd.py", line 1596, in <module>
    globals = debugger.run(setup['file'], None, None, is_module)
  File "/home/gis/Downloads/pycharm-community-2017.2/helpers/pydev/pydevd.py", line 1023, in run
    pydev_imports.execfile(file, globals, locals)  # execute the script
  File "/home/gis/PycharmProjects/guo/SSRN-master/Classification Maps/UP_classification_maps.py", line 220, in <module>
    classification_map(y_re, gt_IN, 24, "../Cmaps/RES4_SS_UP1.png")
  File "/home/gis/PycharmProjects/guo/SSRN-master/Classification Maps/UP_classification_maps.py", line 63, in classification_map
    ax.imshow(map, aspect='normal')
  File "/home/gis/.local/lib/python2.7/site-packages/matplotlib/__init__.py", line 1867, in inner
    return func(ax, *args, **kwargs)
  File "/home/gis/.local/lib/python2.7/site-packages/matplotlib/axes/_axes.py", line 5496, in imshow
    self.set_aspect(aspect)
  File "/home/gis/.local/lib/python2.7/site-packages/matplotlib/axes/_base.py", line 1373, in set_aspect
    aspect = float(aspect)  # raise ValueError if necessary
ValueError: could not convert string to float: normal
不知道如何解决。

猜你喜欢

转载自blog.csdn.net/gdengden/article/details/88541367