def feature_to_image(features, height=28, width=28, channels=1, backend=K):
'''
Reshape a flattened image to the input format for convolutions.
Can be used either as a Keras operation using the default backend or
with numpy by using the argument backend=np
Conforms to the image data format setting defined in ~/.keras/keras.json
'''
if K.image_data_format() == "channels_first":
return backend.reshape(features, (-1, channels, height, width))
else:
return backend.reshape(features, (-1, height, width, channels))
评论列表
文章目录