什么?AI黑白图像能够自动上色?( 四 )

建立数据集如下图所示:

然后导入所有的库

from __future__ import absolute_import from __future__ import division from __future__ import print_function import tensorflow as tf import numpy as np import argparse import os import json import glob import random import collections import math import time 接着建立网络层 , 以及生成器和判别器的对抗性网络 with tf.variable_scope( \"layer_1\" ): convolved=discrim_conv(inputa.ndfstride= 2 ) rectified=lrelu(convolved 0.2 ) layers.append(rectified) #layer_2:[batch 128 128 ndf
=[batch 64 64 ndf* 2
#layer_3:[batch 64 64 ndf* 2
=[batch 32 32 ndf* 4
#layer_4:[batch 32 32 ndf* 4
=[batch 31 31 ndf* 8
for i in range(n_layers): with tf.variable_scope( \"layer_%d\" %(len(layers)+ 1 )): out_channels=a.ndf*min( 2 **(i+ 1 ) 8 ) stride= 1 if i==n_layers- 1 else 2 #lastlayerherehasstride 1 convolved=discrim_conv(layers[ -1

推荐阅读