Skip to content

Instantly share code, notes, and snippets.

View zeryx's full-sized avatar

zeryx zeryx

View GitHub Profile
/*
* File: ClassDefinitions.h
* Author: James
*
* Created on February 4, 2014, 12:50 PM
*/
#ifndef CLASSDEF_H
#define CLASSDEF_H
#include "structs.h"
for(int i=0;i<num_hidden;i++)
{
for(int j=0;j<innum;j++)
{
hidden_val[i]+= inputs[j][x].data*current[person_num][wt_ctr++].weight;
}
hidden_val[i]+= 1*current[person_num][wt_ctr++].weight;
hidden_val[i] = Activation_sig(hidden_val[i]);
assert(wt_ctr!=wtqty);
}
current.resize(boost::extents[ini1.popsize][ini1.wtqt]);
if(iter==0) // if this is the first iteration, populate with randoms
{
for(int j=0;j<ini1.popsize;j++) // create individuals
{
for(int k=0;k<ini1.wtqt;k++) // randomize the "genes" (weights in this case) for the entire chroma
{
current[j][k].weight=RNG_normal( prob.RNG_SD );
}
}
@zeryx
zeryx / networkKernel.cu
Created September 4, 2015 18:24
command queue if/else block
for(int itr=0; itr< params.array[26]; itr++){//every order is sequential and run after the previous order to massively simplify the workload in this kernel.
double tmp;
//set stuff to zero
if(commandQueue[itr].first.def == typeHidden && commandQueue[itr].second.def == typeZero){
neuroZero(Vec.array[hiddenOffset+commandQueue[itr].first.id*ind]);
}
else if(commandQueue[itr].first.def == typeMemGateIn && commandQueue[itr].second.def == typeZero){
neuroZero(Vec.array[memGateInOffset+commandQueue[itr].first.id*ind]);
@zeryx
zeryx / checkAccountID.scala
Last active November 22, 2015 21:13
titan does create an index, but while using the index with the query in checkAccountID.scala, it fails to find matching verticies.
def doesAccountIDExist(id: Int): Boolean = {
///this is the line that fails
val tmp = g._graph.V.hasLabel("account").has(accountIDKey -> id).toList()
g._graph.tx().commit()
if (tmp.nonEmpty) Console.println("Success, index works.")
}
@zeryx
zeryx / gist:0cf025567791c835f36e
Last active January 18, 2016 15:02
edit profile case class
case class EditProfileForm(accountID: Int,
localProfileID: Int,
profileName: Option[String],
profileGender: Option[Int],
profileBirthday: Option[String])
@zeryx
zeryx / constructor_matching.scala
Last active January 22, 2016 17:53
generic apply method constructors
/**
* Created by james on 22/01/16.
*/
sealed class GenericRecommender extends Constructors{
def apply(constructor: GenericConstructor){
constructor match{
trait ConnectionInMemory {
var graph: TitanGraph = null
def connect() = {
import org.apache.commons.configuration.BaseConfiguration
val conf = new BaseConfiguration()
conf.setProperty("storage.backend","inmemory")
import com.thinkaurelius.titan.core.TitanFactory
graph = TitanFactory.open(conf)
object TitanCon extends InMemory with InCassandra{
lazy var Graph: TitanGraph
def connect(backendType: String): Unit = {
Graph = backendType match {
case "inMemory" => memoryConnect()
case "inCassandra" => cassandraConnect()
"properly accept a new account request" in {
Post("account/new", NewAccountForm(100, "zeryx")) ~> check{
val json = parse(responseAs[String])
val check: String = (for{
JString(returnType) <- (json \ "RETURN CODE").toOption
} yield returnType).getOrElse("None")
("RETURN CODE" -> check) === Frontend.success