1.convolution.py

import numpy as np
from sklearn.datasets import load_sample_images
import tensorflow as tf
import matplotlib.pyplot as plt dataset = np.array(load_sample_images().images, dtype=np.float32)
batch_size, height, width, channels = dataset.shape print(batch_size, height, width, channels) print(type(dataset)) filters_test = tf.placeholder(tf.float32, shape=(15, 15, channels, 2)) X = tf.placeholder(tf.float32, shape=(None, height, width, channels)) dataset = dataset/255 convolution = tf.nn.conv2d(X, filter=filters_test, strides=[1, 2, 2, 1], padding='SAME') with tf.Session() as sess:
out = {}
filters = np.zeros(shape=(15, 15, channels, 2))
for i in range(2):
if i == 0:
filters[7, :, :, 1] = 1
elif i == 1:
filters[:, 7, :, 1] = 1
output = sess.run(convolution, feed_dict={X: dataset, filters_test: filters}) print(output)
out['output'+str(i)] = output print(output) plt.imshow(dataset[0])
plt.show() for i in out:
# print(out[i])
# max_value = max(out[i][0].reshape(-1, 1))
# print(max_value)
# out[i] = out[i]/max_value plt.title(i)
plt.imshow(255*out[i][0, :, :, 1], cmap='bone')
plt.show()

最新文章

  1. css 图片的无缝滚动
  2. mysql 表被锁处理方案
  3. formValidator的一些验证实例
  4. 今天学习到的关于mysql数据库的linux命令
  5. msmms (一) sms与mms区别
  6. linux解压命令
  7. WAJUEJI which home strong!
  8. F# 可以把几个函数组合成新函数
  9. 5 Logistic回归(二)
  10. 如何使用Visual Studio 2013 开发PHP5.6项目
  11. 【一天一道LeetCode】#30. Substring with Concatenation of All Words
  12. Linux----------nfs服务器的搭建及常识
  13. 初识大数据(二. Hadoop是什么)
  14. mysql解除死锁状态
  15. 从零开始部署一个 Laravel 站点
  16. [CodeForces - 614B] B - Gena's Code
  17. AppStore企业账号打包发布APP流程详解
  18. bash 括号(小括号,双小括号,中括号,双中括号,大括号)
  19. Loitor_产品(一)
  20. day06作业

热门文章

  1. centos和ubuntu的网络属性配置
  2. 使用HBuilderX实现打包vue项目成app
  3. 编程开发之--java多线程学习总结(5)
  4. ltp-ddt eth过程中遇到的问题
  5. Go语言容器
  6. 一段关于Unix、Linux和Windows的暗黑史
  7. C#枚举类型转换
  8. (转)sysbench部署与参数详解
  9. Javascript框架设计思路图
  10. JavaScript设计模式-21.命令模式