[Matplotlib] Flatten()

ax.flatten(): Transform n*m to 1*nm 1-D Array

    fig, ax = plt.subplots(nrows=2,ncols=2,sharex='all',sharey='all')    ax = ax.flatten()       for i in range(4):        img = image[i].reshape(28, 28)        ax[i].imshow(img, cmap='Greys', interpolation='nearest')            # ax[i] is available
Without flatten()
    fig, ax = plt.subplots(nrows=2,ncols=2,sharex='all',sharey='all')      for i in range(4):        img = image[i].reshape(28, 28)        ax[0, 0].imshow(img, cmap='Greys', interpolation='nearest')         ax[0, 1].imshow(img, cmap='Greys', interpolation='nearest')        ax[1, 0].imshow(img, cmap='Greys', interpolation='nearest')        ax[1, 1].imshow(img, cmap='Greys', interpolation='nearest')            # ax[i] is unavailable
Convolutional Neural NetworksWe often use Flatten, converting matrice to vectors.After flattening, then feed the vectors to Fully Connected Layers.CNN -> Pooling -> CNN -> Pooling...-> Flatten -> Fully Connected Layers -> Softmax -> Probabilities

关于作者: 网站小编

码农网专注IT技术教程资源分享平台,学习资源下载网站,58码农网包含计算机技术、网站程序源码下载、编程技术论坛、互联网资源下载等产品服务,提供原创、优质、完整内容的专业码农交流分享平台。

热门文章