This file contains hidden or 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 RemoteCloud { | |
QNetworkAccessManger m_nam; | |
QString URL(QString url); // left as an exercise to the reader, this just maps a short name to a server/versioned endpoint | |
QNetworkReplay *get(const QString& url); | |
QNetworkReply *post(const QString& url, const QVariantMap& object); | |
public: | |
QNetworkReply *get(const QString& endpoint, std::function<void(QNetworkReply*)> lambda, bool sync=false); | |
QNetworkReply *post(const QString& endpoint, |
This file contains hidden or 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 json | |
def load_keras_model(filename): | |
with open(filename) as file: | |
data = file.read() | |
json_object = json.loads(data) | |
model = model_from_json(data) | |
layer_arrays = [] | |
for layer in json_object["weights"]: | |
layer_arrays.append(np.array(layer)) |
This file contains hidden or 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
# Keras tokenizer lacks serialization. Therefore I created the below to address this without changing the API. | |
# (Since I don't know how long it'll take for keras to support it) | |
# The Tokenizer __init__ should be modified to take the word_stats dictionary as a kwarg, | |
# and a method added to the class to return the stats | |
# Expiermentally this works, but I am not sure of any nuances in the Tokenizer class. | |
def test_tokenizer(): | |
texts = ["It was the best of times, it was the worst of times, it was the age of wisdom", | |
"it was the age of foolishness, it was the epoch of belief, it was the epoch of incredulity, ", | |
"it was the season of Light, it was the season of Darkness, it was the spring of hope, ", |
This file contains hidden or 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
function mergeObjects(){ | |
var out = {}; | |
var attrname; | |
for (var i =0; i< arguments.length; i++) | |
for (attrname in arguments[i]) { out[attrname] = arguments[i][attrname]; } | |
return out; | |
} | |
console.log(mergeObjects({a:1}, {b:2})) |
This file contains hidden or 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
function validateObjStructure(obj, structure) { | |
if (structure.length > 0) | |
while (structure[0] == '.') | |
structure = structure.substr(1) | |
console.log('Call:', JSON.stringify(obj), structure) | |
var dot = structure.indexOf('.') | |
var bracket = structure.indexOf('[') | |
var prop; | |
if (dot === -1 && bracket === -1) { // a |