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
const imageElement = document.getElementById('image'); | |
// load the BodyPix model from a checkpoint | |
const net = await bodyPix.load(); | |
// arguments for estimating person segmentation. | |
const outputStride = 16; | |
const segmentationThreshold = 0.5; | |
const personSegmentation = await net.estimatePersonSegmentation(imageElement, outputStride, segmentationThreshold); |
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 RandomAgent: | |
"""Random Agent that will play the specified game | |
Arguments: | |
env_name: Name of the environment to be played | |
max_eps: Maximum number of episodes to run agent for. | |
""" | |
def __init__(self, env_name, max_eps): | |
self.env = gym.make(env_name) | |
self.max_episodes = max_eps |
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
# Use pre-trained universal sentence encoder to build text vector | |
review = hub.text_embedding_column( | |
“review”, “https://tfhub.dev/google/universal-sentence-encoder/1") | |
features = { | |
“review”: np.array([“this movie is a masterpiece”, “this movie was terrible”, …]) | |
} | |
labels = np.array([[1], [0], …]) | |
input_fn = tf.estimator.input.numpy_input_fn(features, labels, shuffle=True) | |
estimator = tf.estimator.DNNClassifier(hidden_units, [review]) | |
estimator.train(input_fn, max_steps=100) |
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
# Download a module and use it to retrieve word embeddings. | |
embed = hub.Module(“https://tfhub.dev/google/nnlm-en-dim50/1") | |
embeddings = embed([“The movie was great!”]) |
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
# Download and use NASNet feature vector module. | |
module = hub.Module( | |
“https://tfhub.dev/google/imagenet/nasnet_large/feature_vector/1") | |
features = module(my_images) | |
logits = tf.layers.dense(features, NUM_CLASSES) | |
probabilities = tf.nn.softmax(logits) |
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
PClass | Sex | Age | Survived | |
---|---|---|---|---|
3rd | male | 22 | no | |
1st | female | 38 | yes | |
3rd | female | 26 | yes | |
1st | female | 35 | yes | |
3rd | male | 35 | no | |
1st | male | 54 | no | |
3rd | male | 2 | no | |
3rd | female | 27 | yes | |
2nd | female | 14 | yes |