<jupyter_start><jupyter_text><jupyter_code># Loading data from pycaret
from pycaret.datasets import get_data
df = get_data('diabetes')
df.head()
df.dtypes
target = df.pop('Class variable')
import pandas as pd
import tensorflow as tf
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
import seaborn as sns
from math import floor, ceil
from pylab import rcParams
from tensorflow import keras

%matplotlib inline
dataset = tf.data.Dataset.from_tensor_slices((df.values, target.values))
for feat, targ in dataset.take(5):
  print ('Features: {}, Target: {}'.format(feat, targ))
train_dataset = dataset.shuffle(len(df)).batch(1)
#simple neural network
def get_compiled_model():
  model = tf.keras.Sequential([
    tf.keras.layers.Dense(10, activation='relu'),
    tf.keras.layers.Dense(10, activation='relu'),
    tf.keras.layers.Dense(1)
  ])

  model.compile(optimizer='adam',
                loss=tf.keras.losses.BinaryCrossentropy(from_logits=True),
                metrics=['accuracy'])
  return model
model = get_compiled_model()
model.fit(train_dataset, epochs=15)
import collections
import matplotlib.pyplot as plt
import numpy as np

import tensorflow as tf

from tensorflow.keras import layers
#LSTM RNN
model = tf.keras.Sequential()
# Add an Embedding layer expecting input vocab of size 1000, and
# output embedding dimension of size 64.
model.add(layers.Embedding(input_dim=1000, output_dim=64))

# Add a LSTM layer with 128 internal units.
model.add(layers.LSTM(128))

# Add a Dense layer with 10 units.
model.add(layers.Dense(10))

model.summary()
model = get_compiled_model()
model.fit(train_dataset, epochs=200)
# GRU RNN 
model = tf.keras.Sequential()
model.add(layers.Embedding(input_dim=1000, output_dim=64))

# The output of GRU will be a 3D tensor of shape (batch_size, timesteps, 256)
model.add(layers.GRU(256, return_sequences=True))

# The output of SimpleRNN will be a 2D tensor of shape (batch_size, 128)
model.add(layers.SimpleRNN(128))

model.add(layers.Dense(10))

model.summary() 
model = get_compiled_model()
model.fit(train_dataset, epochs=200)

model = tf.keras.Sequential()

model.add(layers.Bidirectional(layers.LSTM(64, return_sequences=True), 
                               input_shape=(5, 10)))
model.add(layers.Bidirectional(layers.LSTM(32)))
model.add(layers.Dense(10))

model.summary()
model = get_compiled_model()
model.fit(train_dataset, epochs=200)<jupyter_output>Epoch 1/200
WARNING:tensorflow:Layer dense_12 is casting an input tensor from dtype float64 to the layer's dtype of float32, which is new behavior in TensorFlow 2.  The layer has dtype float32 because it's dtype defaults to floatx.

If you intended to run this layer in float32, you can safely ignore this warning. If in doubt, this warning is likely only an issue if you are porting a TensorFlow 1.X model to TensorFlow 2.

To change all layers to have dtype float64 by default, call `tf.keras.backend.set_floatx('float64')`. To change just this layer, pass dtype='float64' to the layer constructor. If you are the author of this layer, you can disable autocasting by passing autocast=False to the base Layer constructor.

768/768 [==============================] - 1s 1ms/step - loss: 9.2621 - accuracy: 0.5312
Epoch 2/200
768/768 [==============================] - 1s 1ms/step - loss: 0.7846 - accuracy: 0.6419
Epoch 3/200
768/768 [==============================] - 1s 1ms/step - loss: 0.6848 - ac[...]
{'fraction_non_alphanumeric': 0.12882541533080735, 'fraction_numerical': 0.0440104925677645, 'mean_word_length': 4.797297297297297, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, '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': '22677', 'license': 'Apache-2.0', 'n_tokens_mistral': 1232, 'n_tokens_neox': 1093, 'n_words': 347, 'path': 'rnn.ipynb', 'repo_name': 'SAIKARTHIGEYAN1512/ARouter', 'size': '3431'}