<jupyter_start><jupyter_text><jupyter_code>import numpy as np
import pandas as pd
from sklearn import preprocessing
try:
  # %tensorflow_version only exists in Colab.
  %tensorflow_version 2.x
except Exception:
  pass
import tensorflow as tf
import numpy as np
import matplotlib.pyplot as plt
from sklearn.model_selection import train_test_split, cross_val_score, KFold
from PIL import Image
from tensorflow import keras
from tensorflow.keras import datasets,layers,optimizers,Sequential,metrics
class Generator(keras.Model):
  def __init__(self):
    super(Generator,self).__init__()
    #encoder
    self.fc_layer_1 = layers.Dense(3*3*512)
    self.conv_1 = layers.Conv2DTranspose(256,3,3,'valid')

    self.bn_1 = layers.BatchNormalization()       
    self.conv_2 = layers.Conv2DTranspose(128,5,2,'valid')
    self.bn_2 = layers.BatchNormalization()     
    self.conv_3 = layers.Conv2DTranspose(3,4,3,'valid')

  def call(self, inputs, training=None):
    x = self.fc_layer_1(inputs)
    x = tf.reshape(x,[-1,3,3,512])
    x = tf.nn.relu(x)
    x = self.bn_1(self.conv_1(x),training=training)
    x = self.bn_2(self.conv_2(x),training=training)
    x = self.conv_3(x)
    x = tf.tanh(x)
    return x
class Discriminator(keras.Model):
  def __init__(self):
    super(Discriminator,self).__init__()

    self.conv_1 = layers.Conv2D(64,5,3,'valid')
    self.conv_2 = layers.Conv2D(128,5,3,'valid')
    self.bn_1 = layers.BatchNormalization()
    self.conv_3 = layers.Conv2D(256,5,3,'valid')    
    self.bn_2 = layers.BatchNormalization()
    self.flatten = layers.Flatten()
    self.fc_layer = layers.Dense(1)

  
  def call(self, inputs, training=None):
    x = tf.nn.leaky_relu(self.conv_1(inputs))    
    x = tf.nn.leaky_relu(self.bn_1(self.conv_2(x),training=training))    
    x = tf.nn.leaky_relu(self.bn_2(self.conv_3(x),training=training))  
    x = self.flatten(x)
    x = self.fc_layer(x)
    return x
g = Generator()
d = Discriminator()
x = tf.random.normal([1,64,64,3])
z = tf.random.normal([1,100])
prob = g(x)
print(prob)
out = d(x)
print(out.shape)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.13590844062947066, 'fraction_numerical': 0.03719599427753934, 'mean_word_length': 4.205955334987593, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '65868', 'license': 'Apache-2.0', 'n_tokens_mistral': 828, 'n_tokens_neox': 804, 'n_words': 140, 'path': 'GAN_example.ipynb', 'repo_name': 's36934512/tensorpack', 'size': '2097'}