1、手写数字生成
生成图像↓

1.1、普通网络
from keras.datasets import mnist
from keras.utils import to_categorical, plot_model
from keras.models import Sequential
from keras.layers import Dense
import numpy as np, matplotlib.pyplot as mp
# 数据读取、处理
_, (x, y) = mnist.load_data()
x = x.reshape(-1, 28 * 28) / 255
y = to_categorical(y, 10)
# 建模、编译、训练
model = Sequential()
model.add(Dense(128))
model.add(Dense(28 * 28))
model.compile('adam', 'mse')
model.fit(y, x, 512, 10)
plot_model(model, show_shapes=True, show_layer_names=False)
# 图像生成
yy = to_categorical(list(range(10)), 10)
xx = model.predict(yy)
xx = [i.reshape(28, 28) for i in xx]
xx = np.concatenate(xx, axis=1)
mp.imshow(xx

最低0.47元/天 解锁文章
9万+

被折叠的 条评论
为什么被折叠?



