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
# tfcoreml src | |
# file1 : _interpret_shapes.py | |
# | |
# in the _SHAPE_TRANSLATOR_REGISTRY we need to add the Pow operation | |
_SHAPE_TRANSLATOR_REGISTRY = { | |
... previous keys ... | |
# add this: | |
'Pow': _identity, | |
} |
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 ffwd, line 98 | |
# https://github.com/lengstrom/fast-style-transfer/blob/master/evaluate.py#L98 | |
if os.path.isdir(checkpoint_dir): | |
ckpt = tf.train.get_checkpoint_state(checkpoint_dir) | |
if ckpt and ckpt.model_checkpoint_path: | |
saver.restore(sess, ckpt.model_checkpoint_path) | |
########## add this for pre-trained models ########### | |
frozen_graph_def = tf.graph_util.convert_variables_to_constants(sess,sess.graph_def,['add_37']) | |
with open('output_graph.pb', 'wb') as f: | |
f.write(frozen_graph_def.SerializeToString()) |
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 ffwd,line 93 | |
# https://github.com/lengstrom/fast-style-transfer/blob/master/evaluate.py#L93 | |
preds = transform.net(img_placeholder) | |
# !! Add This !! | |
print(preds) |
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
/** | |
* Cyclic Elimination Stage 3 | |
* - description needed | |
*/ | |
function _cycleReduceStage() { | |
let stable = false; | |
// all or nothing phase | |
while(!stable) { | |
// there is a start if any one person has more than 1 preference remaining | |
let start = indexWithMultipleRemain(); |
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
/** | |
* Elimination Stage 2 | |
* - removes all preferences in a list who can not be possibly matched | |
*/ | |
function _eliminateStage() { | |
_.forIn(_DB, (person,id) => { | |
let keepLast = _.findIndex(person.choices, function(p) { return p.id == person.acceptedReceivedID; }); | |
for(let i = keepLast + 1; i < person.choices.length; i++) { | |
// each the rejected and rejecter can remove each other from choices list | |
eliminateChoices(person, _DB[person.choices[i].id]); |
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
// eliminates two people from each others preference list | |
function eliminateChoices(rejecter, rejected) { | |
let remove1 = _.findIndex(rejected.choices, function(p) { return p.id == rejecter.id; }); | |
rejected.choices.splice(remove1, 1); | |
let remove2 = _.findIndex(rejecter.choices, function(p) { return p.id == rejected.id; }); | |
rejecter.choices.splice(remove2, 1); | |
} |
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
// sender has accepted sent, receiver has accepted received | |
function acceptOffer(sender,receiver, receiverRank, senderRank) { | |
sender.hasAcceptedSentProposal = true; | |
sender.acceptedSentRank = receiverRank; | |
sender.acceptedSentID = receiver.id; | |
receiver.hasAcceptedReceivedProposal = true; | |
receiver.acceptedReceivedRank = senderRank; | |
receiver.acceptedReceivedID = sender.id; | |
} |
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
// iterates over the process of sending, accepting, and rejecting proposals | |
function proposalProcess(sender, receiver, receiverRank) { | |
// we now need to check to see if the receiver has accepted proposals and | |
// how the receiver ranks the sender of the proposal | |
let indexOfsender = _.findIndex(receiver.choices, p => { return p.id == sender.id; }); | |
// create shortcut to senders object in receiver's list | |
let senderRank = receiver.choices[indexOfsender].strength; | |
if(receiver.hasAcceptedReceivedProposal) { | |
// need to compare against accept proposal | |
if(receiver.acceptedReceivedRank > senderRank) { |
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
/** | |
* Proposal Stage 1 | |
* - everyone sends out a proposal and they are either accepted or rejected | |
* - recursive until everone has accepted proposal | |
*/ | |
function _proposalStage(start){ | |
let i = typeof start !== 'undefined' ? start : 1; | |
while(i < Object.keys(_DB).length + 1) { | |
let sender = _DB[i]; |
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
var StableMatching = (function (data) { | |
let _DB = data; | |
// this is stage 1 | |
function _proposalStage(refresh){ | |
... | |
} | |
return { | |
init: function(db) { |