This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
import tensorflow as tf | |
from tensorflow.examples.tutorials.mnist import input_data | |
mnist = input_data.read_data_sets("/tmp/data/", one_hot=True) | |
n_h1 = 500 | |
n_h2 = 500 | |
n_classes = 10 | |
batch_size = 128 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
from keras.models import Sequential | |
from keras.datasets import mnist | |
from keras.layers import Dense | |
from keras.utils import np_utils | |
n_classes = 10 | |
batch_size = 128 | |
(X_train, y_train), (X_test, y_test) = mnist.load_data() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import tflearn | |
from tflearn.layers.core import input_data, fully_connected | |
from tflearn.layers.estimator import regression | |
import tflearn.datasets.mnist as mnist | |
X_train, y_train, X_test, y_test = mnist.load_data(one_hot=True) | |
X_train = X_train.reshape([-1, 1]) | |
X_test = X_test.reshape([-1, 1]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<title>TensorFlow Demo!</title> | |
<meta charset='uft-8'> | |
<script src="https://cdn.jsdelivr.net/npm/@tensorflow/tfjs@0.8.0"></script> | |
<script src="TF.js"></script> | |
<head> | |
<body> | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import * as tf from '@tensorflow/tfjs'; | |
// A sequential model is a container which you can add layers to. | |
const model = tf.sequential(); | |
// Add a dense layer with 1 output unit. | |
model.add(tf.layers.dense({units: 10, | |
inputShape: [1], | |
activation='relu' | |
})); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import tflearn | |
import numpy as np | |
x = np.array([[1], [2], [3], [4], [5], [6], [7]], dtype=np.float32) | |
y = np.array([[1], [3], [5], [7], [9], [11], [13]], dtype=np.float32) | |
n = tflearn.input_data(shape=[None, 1]) | |
n = tflearn.fully_connected(n, 1, activation='softmax') | |
n = tflearn.regression(n, optimizer=tflearn.SGD(), loss='categorical_crossentropy') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// A sequential model is a container which you can add layers to. | |
const model = tf.sequential(); | |
// Add a dense layer with 1 output unit. | |
model.add(tf.layers.dense({units: 1, | |
inputShape: [1], | |
activation: 'softmax' | |
})); | |
// Specify the loss type and optimizer for training. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
from sklearn.model_selection import train_test_split | |
def load_cats(): | |
cats = np.load("./cats.npy") | |
print (cats.shape) | |
Y = [] | |
for i in range(cats.shape[0]): | |
Y.append([1,0]) | |
Y = np.array(Y) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class PAgent(): | |
def __init__(self, length): | |
self.string = ''.join(random.choice(string.ascii_letters) for _ in range(length)) | |
self.fitness = -1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class SAgent(): | |
def __init__(self, in_str): | |
self.in_str = in_str | |
self.in_str_len = len(in_str) | |
self.average_score_fitness = -1 | |
self.number_successful = 0 | |
self.population = random.randint(1, 21) | |
self.generations = random.randint(1, 5000) | |
self.threshold = 90 | |
OlderNewer