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
<!-- D3js imports to load CSV data --> | |
<script src="https://d3js.org/d3-collection.v1.min.js"></script> | |
<script src="https://d3js.org/d3-dispatch.v1.min.js"></script> | |
<script src="https://d3js.org/d3-dsv.v1.min.js"></script> | |
<script src="https://d3js.org/d3-request.v1.min.js"></script> | |
<script src="https://d3js.org/d3-queue.v3.min.js"></script> | |
<!-- load multiple data asynchronously, defer visualization until complete --> | |
d3.queue() | |
.defer(d3.csv, "./data/spotmeka_points.csv") |
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
// Pointcloud | |
pointGeometry = new THREE.BufferGeometry(); | |
var pointArray = []; | |
var colorArray = []; | |
for (i = 0; i < points_dataset.length; i++) { | |
// Space apart ARKit points appropriately into new environment | |
var x = points_dataset[i]["x"] * POINT_SPACING; | |
var y = points_dataset[i]["y"] * POINT_SPACING; |
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
# Count the unique characters in the file | |
vocab = sorted(set(text)) | |
# Creating a mapping from unique characters to indices | |
char2idx = {u:i for i, u in enumerate(vocab)} | |
idx2char = np.array(vocab) | |
text_as_int = np.array([char2idx[c] for c in text]) | |
print (f'Training set contains {len(vocab)} unique characters') | |
print (f'First 20 characters -> index mappings') |
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
def split_input_target(chunk): | |
input_text = chunk[:-1] | |
target_text = chunk[1:] | |
return input_text, target_text | |
BATCH_SIZE = 64 | |
BUFFER_SIZE = 10000 | |
# Create TensorFlow training examples and targets | |
char_dataset = tf.data.Dataset.from_tensor_slices(text_as_int) |
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
def build_model(vocab_size, embedding_dim, rnn_units, batch_size): | |
dropout_rate = 0.2 | |
rnn_initializer = 'glorot_uniform' | |
model = tf.keras.Sequential([ | |
tf.keras.layers.Embedding(vocab_size, embedding_dim, | |
batch_input_shape=[batch_size, None]), | |
tf.keras.layers.Dropout(dropout_rate), | |
tf.keras.layers.LSTM(rnn_units, | |
return_sequences=True, |
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
# Define loss function | |
def loss(labels, logits): | |
return tf.keras.losses.sparse_categorical_crossentropy(labels, logits, from_logits=True) | |
# Compile model | |
model.compile(optimizer='adam', loss=loss) | |
# Directory where the checkpoints will be saved | |
checkpoint_dir = './training_checkpoints' |
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
def validate_csv(text, field_count=4): | |
# Quick validation check to make sure input is sane | |
return len(text.split(", ")) == field_count | |
def generate_rec(model, start_string, num_chars, temperature, expected_field_count): | |
invalid_record_count = 0 | |
valid_record_count = 0 | |
# Convert our start string to numbers (vectorizing) | |
input_eval = [char2idx[s] for s in start_string] |
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
logging.info("Utilizing differential privacy in optimizer" | |
RMSPropOptimizer = tf.compat.v1.train.RMSPropOptimizer | |
DPRmsPropGaussianOptimizer = make_dp_gaussian_optimizer(RMSPropOptimizer) | |
optimizer = DPRmsPropGaussianOptimizer( | |
l2_norm_clip=store.l2_norm_clip, | |
noise_multiplier=store.noise_multiplier, | |
num_microbatches=store.microbatches, |
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
# training settings | |
max_chars: 0 # use a non-zero number to limit training data | |
epochs: 30 # number of training epochs (typically 15-30) | |
# RNN settings | |
batch_size: 64 # training batches | |
buffer_size: 10000 # maximum buffer size | |
seq_length: 100 # max length sentence for a single input in characters | |
embedding_dim: 256 # the embedding dimension | |
rnn_units: 256 #1024 # number of RNN units |
OlderNewer