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
import { Web5 } from "@web5/api"; | |
import {readFileSync,appendFileSync,appendFile, unlinkSync} from "fs" | |
import { LevelStore } from '@web5/common'; | |
import { EdDsaAlgorithm } from '@web5/crypto'; | |
const { web5, did: myDid } = await Web5.connect({sync: '5s'}); | |
let i_am=""; | |
const roman_did= `did:ion:EiCfpN21p6o7dD9NImXtct5knTkOGhYy9OlSs0hdiCsrIQ:eyJkZWx0YSI6eyJwYXRjaGVzIjpbeyJhY3Rpb24iOiJyZXBsYWNlIiwiZG9jdW1lbnQiOnsicHVibGljS2V5cyI6W3siaWQiOiJkd24tc2lnIiwicHVibGljS2V5SndrIjp7ImNydiI6IkVkMjU1MTkiLCJrdHkiOiJPS1AiLCJ4IjoicFZJcGZzX3c5YXhsU3ZGVFVWU2hSRzRuZDdCQ2RobzZ3Y0wxRms4dHB4VSJ9LCJwdXJwb3NlcyI6WyJhdXRoZW50aWNhdGlvbiJdLCJ0eXBlIjoiSnNvbldlYktleTIwMjAifSx7ImlkIjoiZHduLWVuYyIsInB1YmxpY0tleUp3ayI6eyJjcnYiOiJzZWNwMjU2azEiLCJrdHkiOiJFQyIsIngiOiJlX0tvTDRRZnJuZWlNSGpDWFpGNjREaWU0Vjh6NjJZaE5vN1Bzc3lRXzhRIiwieSI6IjFYZ1JsTWJfR3FqNXBaTHRzMUxlcmRQaUowN1hSNzNRX0ZyT0FtbVBCdm8ifSwicHVycG9zZXMiOlsia2V5QWdyZWVtZW50Il0sInR5cGUiOiJKc29uV2ViS2V5MjAyMCJ9XSwic2VydmljZXMiOlt7ImlkIjoiZHduIiwic2VydmljZUVuZHBvaW50Ijp7ImVuY3J5cHRpb25LZXlzIjp |
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 passphrase = "passphrase typed in from user interface" | |
const private_key_restored_from_db = "uint8array_base64_encoded_on_db" | |
const public_key_restored_from_db = "uint8array_base64_encoded_on_db_pub" | |
let appData = new AppDataVault({ | |
store: new LevelStore('DATA/AGENT/APPDATA') | |
}); | |
const options={ | |
algorithm : { name: 'EdDSA', namedCurve: 'Ed25519' }, |
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
package ch.ethz.dalab.dissolve.examples.neighbourhood | |
import cc.factorie.la._ | |
import scala.collection.mutable.ArrayBuffer | |
import scala.collection.Set | |
import cc.factorie.util.{DoubleSeq, RangeIntSeq, SparseDoubleSeq} | |
import scala.collection.mutable |
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
package ch.ethz.dalab.dissolve.examples.neighbourhood | |
import cc.factorie.la._ | |
import scala.collection.mutable.ArrayBuffer | |
import scala.collection.Set | |
import cc.factorie.util.{DoubleSeq, RangeIntSeq, SparseDoubleSeq} | |
import scala.collection.mutable |
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
/* | |
Exception in thread "main" java.lang.ClassCastException: breeze.linalg.Transpose cannot be cast to breeze.linalg.ImmutableNumericOps | |
at ch.ethz.dalab.dissolve.optimization.SolverUtils$.objectiveFunction(SolverUtils.scala:52) | |
at ch.ethz.dalab.dissolve.optimization.DBCFWSolverTuned.ch$ethz$dalab$dissolve$optimization$DBCFWSolverTuned$$evaluateModel$1(DBCFWSolverTuned.scala:237) | |
at ch.ethz.dalab.dissolve.optimization.DBCFWSolverTuned$$anonfun$optimize$1.apply$mcZI$sp(DBCFWSolverTuned.scala:375) | |
at ch.ethz.dalab.dissolve.optimization.DBCFWSolverTuned$$anonfun$optimize$1.apply(DBCFWSolverTuned.scala:359) | |
at ch.ethz.dalab.dissolve.optimization.DBCFWSolverTuned$$anonfun$optimize$1.apply(DBCFWSolverTuned.scala:359) | |
at scala.collection.immutable.Stream.takeWhile(Stream.scala:803) | |
at ch.ethz.dalab.dissolve.optimization.DBCFWSolverTuned.optimize(DBCFWSolverTuned.scala:358) | |
at ch.ethz.dalab.dissolve.classification.StructSVMWithDBCFW.trainModel(StructSVMWithDBCFW.scala:24) |
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
val Q = DenseMatrix.ones[Double](numRegions, numClasses) | |
var lastMaxE = 0.0 | |
var lastMinE = 0.0 | |
var numNoChange = 0 | |
for (iter <- 0 until maxIterations) { | |
var numUnchangedQs = 0 | |
val lastQ = Q; | |
val xiLab = (0 until numClasses).par |
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
val Q = DenseMatrix.ones[Double](numRegions, numClasses) //TODO maybe initialize to 1/num neighbours or 1/numneighbours*numClass | |
//TODO This Q could be stored in a spark RDD if it gets too large for memory;; Prob not necesary because thetaUnayr is the same size | |
//TODO consider storing the probabilities in a byte | |
if (debug) { | |
//val header = (0 until numClasses).toSeq.toList.flatMap { curclass => (0 until numRegions).toSeq.toList.map { curregion => ",Qr" + curregion + " Qc" + curclass } } | |
// println("#MF_Q_LOG#,timeID,elapsedTime" + header) | |
// println("#MF_E_LOG#,timeID,logTag,iter,maxE,minE,maxE_change,minE_change") | |
} | |
var lastMaxE = 0.0 |
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 RegionVar(val score: Int) extends IntegerVariable(score) | |
object PixelDomain extends DiscreteDomain(numClasses) | |
class Pixel(i: Int) extends DiscreteVariable(i) { //i is just the initial value | |
def domain = PixelDomain | |
} | |
val labelParams = Array.fill(graph.size) { new Pixel(0) } | |
val nodePairsUsed: HashSet[(Int, Int)] = new HashSet[(Int, 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
{ | |
"d":{ | |
"__type":"Response:http:\/\/research.microsoft.com", | |
"Author":null, | |
"Conference":null, | |
"Domain":null, | |
"Journal":null, | |
"Keyword":null, | |
"Organization":null, | |
"Publication":{ |
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
protected ArrayList<String> wildWithInpAtBack(String inp,int ngramLength){ | |
ArrayList<String> out = new ArrayList<String>(ngramLength); | |
for(int i=0;i<ngramLength-1;i++){ | |
out.add(i, FirstSentSum.WILDCARD_STRING); | |
} | |
if(inp.indexOf(" ")!=-1){ | |
for(String sepI : inp.split(" ")){ | |
out.add(sepI); | |
} | |
} |