def visualize_pool1(vis_video, dep_video, video_index, result_dir):

    for t in xrange(vis_video.shape[0]):

        # プーリング1層まで通した結果を出力
        draw_image(xparray(model.extract_pool11(vis_video[t,:,:]).data), '%s/sample_vis_pool1_%d_%d.jpg' % (result_dir, video_index, t))
        draw_image(xparray(model.extract_pool21(dep_video[t,:,:]).data), '%s/sample_dep_pool1_%d_%d.jpg' % (result_dir, video_index, t))
def visualize_pool1(vis_video, dep_video, video_index, result_dir):

    for t in xrange(vis_video.shape[0]):

        # プーリング1層まで通した結果を出力
        draw_image(
            xparray(model.extract_pool11(vis_video[t, :, :]).data),
            '%s/sample_vis_pool1_%d_%d.jpg' % (result_dir, video_index, t))
        draw_image(
            xparray(model.extract_pool21(dep_video[t, :, :]).data),
            '%s/sample_dep_pool1_%d_%d.jpg' % (result_dir, video_index, t))
Exemple #3
0
        # CNNで各層を可視化
        # 1,2層の可視化
        if epoch % args.visualize == 0:
            draw_filters(xparray(model.conv11.W), '%s/log_conv11_epoch_%d.jpg' % (result_dir, epoch))
            draw_filters(xparray(model.conv21.W), '%s/log_conv21_epoch_%d.jpg' % (result_dir, epoch))
            draw_filters_sq(xparray(model.conv12.W), '%s/log_conv12_epoch_%d.jpg' % (result_dir, epoch), 16)
            draw_filters_sq(xparray(model.conv22.W), '%s/log_conv22_epoch_%d.jpg' % (result_dir, epoch), 16)

            # 適当なファイルの画像を入力する
            video_num = int(np.random.random() * len(test_vis))
            s_image_vis = xp.asarray(test_vis[video_num]).astype(np.float32)
            s_image_dep = xp.asarray(test_dep[video_num]).astype(np.float32)
       
            # プーリング1層まで通した結果を出力
            frame_num = int(s_image_vis.shape[0]/ 2)
            draw_image(xparray(model.extract_pool11(s_image_vis[frame_num,:,:]).data), '%s/sample_vis_pool1_%d.jpg' % (result_dir, epoch))
            draw_image(xparray(model.extract_pool21(s_image_dep[frame_num,:,:]).data), '%s/sample_dep_pool1_%d.jpg' % (result_dir, epoch))

        # 学習曲線を出力
        draw_loss_curve(log_fn, '%s/log.jpg' % result_dir)

        print("Confusion Matrix for train data:")
        print_confmat(conf_array_train)

        print("Confusion Matrix for test data:")
        print_confmat(conf_array_test)

        np.savetxt('%s/confmat_train_epoch_%d.csv' % (result_dir, epoch), conf_array_train, delimiter=',', fmt='%d')
        np.savetxt('%s/confmat_test_epoch_%d.csv' % (result_dir, epoch), conf_array_test, delimiter=',', fmt='%d')
        
        # テストセットの予測を出力