Skip to content

Instantly share code, notes, and snippets.

View treper's full-sized avatar

Maybe treper

  • Shanghai
View GitHub Profile
@treper
treper / autoencoder.cpp
Created August 4, 2013 04:35
draft code
#include <iostream>
#include <Eigen/Dense>
#include <Eigen/Array>
using namespace Eigen;
using namespace std;
void sigmoid(MatrixXf& input, MatrixXf& output)
{
output = (1+ (input.array().exp()).array()).array().inverse();
@treper
treper / new.scala
Last active December 20, 2015 12:19
import scala.collection.mutable.ArrayBuffer
val name = """\[\d+,\d+,\d+\]""".r
val name2 = """\[(\d+),(\d+),\d+]""".r
def parseLine(line: String): ArrayBuffer[String] = {
val jsonstr = line.split("\t")(1)
val result = ArrayBuffer[String]()
val m = name.findAllIn(jsonstr)
val itemIdfArray = ArrayBuffer[Pair[Int, Int]]()
m.foreach(a => { val name2(item, idfnum) = a; val p: Pair[Int, Int] = Pair(item.toInt, idfnum.toInt); itemIdfArray += p; })
if (itemIdfArray.length > 1) {
@treper
treper / LabelPropagation.scala
Created July 31, 2013 08:20
label propagation using graphx
val g = GraphLoader.textFile(sc, fname, a => 1.0F).withPartitioner(numVPart, numEPart).cache()
@treper
treper / LabelPropagation.scala
Created July 31, 2013 08:20
label propagation using graphx
val g = GraphLoader.textFile(sc, fname, a => 1.0F).withPartitioner(numVPart, numEPart).cache()
@treper
treper / CooccurrenceMatrix.scala
Last active December 20, 2015 09:59
calculate a word co-occurrence matrix,scala json parser is not thread safe,use json4s
import scala.util.parsing.json._
import org.json4s._
import org.json4s.native.JsonMethods._
import scala.collection.mutable.ArrayBuffer
def parseLine(line:String):ArrayBuffer[String]={
val jsonstr = line.split("\t")(1)
val a=JSON.parseFull(jsonstr)
val result=ArrayBuffer[String]()
if(a!=None){
val itemIdfArray = ArrayBuffer[Pair[Int,Int]]()