<jupyter_start><jupyter_text>AutoEncoder<jupyter_code>import pandas as pd
import numpy as np

dataset = "YOUR_DATASET" # DATAFRAME

display(dataset)
train_X = "YOUR TRAINING INPUT" # NUMPY
train_Y = "YOUR TRAINING LABEL" # NUMPY

print(train_X.shape)
print(train_Y.shape)
val_X = "YOUR VALIDATION LABEL" # NUMPY
val_Y = "YOUR VALIDATION LABEL" # NUMPY

print(val_X.shape)
print(val_Y.shape)
# shuffling
import random

shuf = np.array([i for i in range(train_X.shape[0])])
random.shuffle(shuf)

train_X = train_X[shuf]
train_Y = train_Y[shuf]

print(train_X.shape)
print(train_Y.shape)
#######################################################################################

from tensorflow.config.experimental import list_physical_devices, set_memory_growth
gpus = list_physical_devices('GPU')
display(gpus)
if gpus:
  try:
    set_memory_growth(gpus[0], True)
  except RuntimeError as e:
    print(e)
    
#######################################################################################
from tensorflow.keras.models import Sequential
from tensorflow.keras.layers import "YOUR LAYER"
from tensorflow.keras.optimizers import "YOUR OPTIMIZER"
from tensorflow.keras.metrics import "YOUR METRIC"
from tensorflow.keras.backend import clear_session

clear_session()

z_dim = 100

encoder = Sequential(name="encoder")
# MODEL
#######################################################################################

    

#######################################################################################

encoder.summary()


decoder = Sequential(name="decoder")
# MODEL
#######################################################################################

    

#######################################################################################

decoder.summary()

model = Sequential(name="Autoencoder")
model.add(encoder)
model.add(decoder)

model.summary()
model.compile(loss='YOUR LOSS', optimizer="YOUR OPTIMIZER", metrics=["YOUR METRIC"])
history = model.fit(train_X, train_X, validation_data=(valid_X, valid_X), 
                    batch_size="YOUR BATCH SIZE", epochs="YOUR EPOCHS", shuffle=True, verbose=1)
# graph
import matplotlib.pyplot as plt

loss = history.history['loss']
val_loss = history.history['val_loss']

epochs = range(1,len(loss) + 1)

plt.plot(epochs, loss, 'r', label='Training Loss')
plt.plot(epochs, val_loss, 'b', label='Validation Loss')
plt.title('Training Loss vs Validation Loss')
plt.xlabel('Epochs')
plt.ylabel('Loss')
plt.legend()
plt.show()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.3050376834589449, 'fraction_numerical': 0.0031733439111463705, 'mean_word_length': 7.378737541528239, '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': '151997', 'license': 'MIT', 'n_tokens_mistral': 838, 'n_tokens_neox': 767, 'n_words': 158, 'path': 'Machine_Learning/tensorflow&keras/AutoEncoder.ipynb', 'repo_name': 'godic97/ILoveVanilaIcecream', 'size': '2521'}