<jupyter_start><jupyter_text>Normalize data<jupyter_code>data_mean = np.mean(enhanced_train_data_inputs, axis=0)
data_std = np.std(enhanced_train_data_inputs, axis=0)

norm_enhanced_train_data_inputs = (enhanced_train_data_inputs - data_mean) / data_std
#data_std<jupyter_output><empty_output><jupyter_text>Split dataset into training validation and test set<jupyter_code>from sklearn.model_selection import train_test_split
X_train, X_test, y_train, y_test = train_test_split(norm_enhanced_train_data_inputs, enhanced_train_data_labels, test_size=0.4, random_state=42)
X_valid, X_test, y_valid, y_test = train_test_split(X_test, y_test, test_size=0.5, random_state=42)
list1 = list(range(0,10))
list2 = list(range(0,10))
train_test_split(list1, list2, test_size=0.2, random_state=5)
X_train.shape<jupyter_output><empty_output><jupyter_text>Create model<jupyter_code>def pong_dense_model():
    inputs = tf.placeholder(dtype=tf.float32, shape=[None, 8])
    
    y = tf.placeholder(dtype=tf.float32, shape=[None, 3])
    
    h1 = tf.layers.dense(inputs, 20, activation=tf.nn.relu)
    h2 = tf.layers.dense(h1, 20, activation=tf.nn.relu)
    h3 = tf.layers.dense(h2, 10, activation=tf.nn.relu)
    
    logits = tf.layers.dense(h3, 3, activation=None)

    sc = tf.nn.softmax_cross_entropy_with_logits(logits=logits, labels=y)

    cost = tf.reduce_mean(sc)

    # Accuracy
    correct_pred = tf.equal(tf.argmax(logits, 1), tf.argmax(y, 1))
    accuracy = tf.reduce_mean(tf.cast(correct_pred, tf.float32), name='accuracy')
    
    return inputs, y, logits, cost, accuracy
    
#from pong_model import pong_model

# Remove previous weights, bias, inputs, etc..
tf.reset_default_graph()


inputs, y, logits, cost, accuracy = pong_dense_model()

optimizer = tf.train.AdamOptimizer(0.01).minimize(cost)


from random import shuffle
import sklearn
from sklearn.model_selection import train_test_split
import matplotlib

epochs = 10000
#atch_size = 1000

cost_list = []
acc_list = []

with tf.Session() as sess:
    # Initializing the variables
    sess.run(tf.global_variables_initializer())

    for e in range(epochs):
                
        #for b in range(0, 800, batch_size):

        cost_value, _ = sess.run([cost, optimizer], feed_dict={
            inputs: X_train,
            y: y_train
        })

        if e % 500 == 0:
            print("Epoch: {} Cost: {}".format(e, cost_value))

        cost_list.append(cost_value)

        acc_value = sess.run(accuracy, feed_dict={
            inputs: X_valid,
            y: y_valid
        })
                
        acc_list.append(acc_value)

        if e % 500 == 0:
            print("Accuracy: {}".format(acc_value))
            print("")
     
    #Calculate final accuracy
    final_acc = sess.run(accuracy, feed_dict={
            inputs: X_test,
            y: y_test
        })

             
    plt.plot(cost_list)
    plt.show()
    plt.plot(acc_list)
    plt.show()
    print("Final accuracy: {}".format(final_acc))
            
    saver = tf.train.Saver()
    save_path = saver.save(sess, "./model/model2.ckpt")<jupyter_output>Epoch: 0 Cost: 1.1327524185180664
Accuracy: 0.3624250590801239

Epoch: 500 Cost: 0.3396291732788086
Accuracy: 0.8134576678276062

Epoch: 1000 Cost: 0.2848663032054901
Accuracy: 0.8094603419303894

Epoch: 1500 Cost: 0.26006993651390076
Accuracy: 0.8341106176376343

Epoch: 2000 Cost: 0.24427221715450287
Accuracy: 0.8341106176376343

Epoch: 2500 Cost: 0.24237866699695587
Accuracy: 0.8500999212265015

Epoch: 3000 Cost: 0.2026253044605255
Accuracy: 0.8634243607521057

Epoch: 3500 Cost: 0.19453008472919464
Accuracy: 0.8647568225860596

Epoch: 4000 Cost: 0.22615908086299896
Accuracy: 0.8500999212265015

Epoch: 4500 Cost: 0.1779916137456894
Accuracy: 0.8760825991630554

Epoch: 5000 Cost: 0.18019352853298187
Accuracy: 0.8734177350997925

Epoch: 5500 Cost: 0.16696207225322723
Accuracy: 0.8827448487281799

Epoch: 6000 Cost: 0.16450820863246918
Accuracy: 0.8840773105621338

Epoch: 6500 Cost: 0.16639916598796844
Accuracy: 0.8787475228309631

Epoch: 7000 Cost: 0.15615050494670868
Accuracy: 0.8920719[...]
{'fraction_non_alphanumeric': 0.10916179337231968, 'fraction_numerical': 0.155458089668616, 'mean_word_length': 3.8579881656804735, 'pattern_counts': {'":': 0, '<': 12, '<?xml version=': 0, '>': 12, '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': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '258684', 'license': 'MIT', 'n_tokens_mistral': 1991, 'n_tokens_neox': 1555, 'n_words': 292, 'path': '.ipynb_checkpoints/train_pong-checkpoint.ipynb', 'repo_name': 'pilotorobo/pongplay_conv', 'size': '4104'}