Skip to content

Instantly share code, notes, and snippets.

View backnotprop's full-sized avatar
📟
E.Alderson

Michael Ramos backnotprop

📟
E.Alderson
View GitHub Profile
var StableMatching = (function (data) {
let _DB = data;
// this is stage 1
function _proposalStage(refresh){
...
}
return {
init: function(db) {
var StableMatching = (function (data) {
let _DB = data;
// this is stage 1
function _proposalStage(refresh){
...
}
return {
init: function(db) {
/**
* 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];
// 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) {
// 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;
}
// 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);
}
/**
* 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]);
/**
* 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();
# 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)
# 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())