1 Star 0 Fork 0

scabiosa/DenoisingAutoEncoder

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
utils.py 1.33 KB
一键复制 编辑 原始数据 按行查看 历史
Mendrika Ramarlina 提交于 2013-02-09 14:22 . New noise class, layers class
import gzip
import cPickle
from PIL import Image
import numpy
import sys
def makeMultiClass(y):
u = numpy.unique(y)
coords = {}
for idx in range(len(u)):
coords[str(u[idx])] = idx
V = numpy.zeros((len(y), len(u)))
for idx in range(len(y)):
V[idx, coords[str(y[idx])]] = 1
return V
def load_mnist():
f = gzip.open("mnist/mnist.pkl.gz", 'rb')
train, valid, test = cPickle.load(f)
f.close()
return train
def scale(X, eps=1e-8):
return (X - X.min())/ (X.max() + eps)
def saveTiles(X, img_shape, tile_shape, tile_spacing=(0, 0), filename="Results/res_DA.png"):
out_shape = [(ishp + tsp) * tshp - tsp for ishp, tshp, tsp
in zip(img_shape, tile_shape, tile_spacing)]
H, W = img_shape
Hs, Ws = tile_spacing
out_array = numpy.zeros(out_shape, dtype='uint8')
for tile_row in xrange(tile_shape[0]):
for tile_col in xrange(tile_shape[1]):
if tile_row * tile_shape[1] + tile_col < X.shape[0]:
img = scale(X[tile_row * tile_shape[1] + tile_col].reshape(img_shape))
out_array[
tile_row * (H+Hs): tile_row * (H + Hs) + H,
tile_col * (W+Ws): tile_col * (W + Ws) + W
] \
= img * 255
img = Image.fromarray(out_array)
img.save(filename)
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/scabiosa/DenoisingAutoEncoder.git
git@gitee.com:scabiosa/DenoisingAutoEncoder.git
scabiosa
DenoisingAutoEncoder
DenoisingAutoEncoder
master

搜索帮助

0d507c66 1850385 C8b1a773 1850385