Example #1
0
void STPConnection::init() 
{
	if ( src->get_rank_size() > 0 ) {
		// init of STP stuff
		tau_d = 0.2;
		tau_f = 1.0;
		Urest = 0.3;
		Ujump = 0.01;
		state_x = auryn_vector_float_alloc( src->get_rank_size() );
		state_u = auryn_vector_float_alloc( src->get_rank_size() );
		state_temp = auryn_vector_float_alloc( src->get_rank_size() );
		for (NeuronID i = 0; i < src->get_rank_size() ; i++)
		{
			   auryn_vector_float_set (state_x, i, 1 ); // TODO
			   auryn_vector_float_set (state_u, i, Ujump );
		}

	}

	// registering the right amount of spike attributes
	// this line is very important finding bugs due to 
	// this being wrong or missing is hard 
	src->set_num_spike_attributes(1);

}
Example #2
0
void IF2Group::clear()
{
	clear_spikes();
	for (NeuronID i = 0; i < get_rank_size(); i++) {
	   auryn_vector_float_set (mem, i, e_rest);
	   auryn_vector_float_set (thr, i, 0.);
	   auryn_vector_float_set (g_ampa, i, 0.);
	   auryn_vector_float_set (g_gaba, i, 0.);
	   auryn_vector_float_set (g_nmda, i, 0.);
	}
}
Example #3
0
void TIFGroup::clear()
{
	clear_spikes();
	for (NeuronID i = 0; i < get_rank_size(); i++) {
	   auryn_vector_float_set (mem, i, e_rest);
	   auryn_vector_ushort_set (ref, i, 0);
	   auryn_vector_float_set (g_ampa, i, 0.);
	   auryn_vector_float_set (g_gaba, i, 0.);
	   auryn_vector_float_set (bg_current, i, 0.);
	}
}
Example #4
0
void STPConnection::push_attributes()
{
	SpikeContainer * spikes = src->get_spikes_immediate();
	for (SpikeContainer::const_iterator spike = spikes->begin() ;
			spike != spikes->end() ; ++spike ) {
		// dynamics 
		NeuronID spk = src->global2rank(*spike);
		double x = auryn_vector_float_get( state_x, spk );
		double u = auryn_vector_float_get( state_u, spk );
		auryn_vector_float_set( state_x, spk, x-u*x );
		auryn_vector_float_set( state_u, spk, u+Ujump*(1-u) );

		// TODO spike translation or introduce local_spikes function in SpikingGroup and implement this there ... (better option)
		src->push_attribute( x*u ); 
	}
}
Example #5
0
void SpikingGroup::load_input_line(NeuronID i, const char * buf)
{
		int nums_now, bytes_now;
		int bytes_consumed = 0, nums_read = 0;
		float temp;

		// read the state_vectors
		for ( map<string,auryn_vector_float *>::const_iterator iter = state_vectors.begin() ; 
			iter != state_vectors.end() ;
			++iter ) {
			if ( ( nums_now = sscanf( buf + bytes_consumed, "%f%n", & temp, & bytes_now ) ) <= 0 )
			{
				// error handling
				logger->msg("Expected additional fields for single neuron parameters. Corrupted nstate file? Aborting.",ERROR);
				return;
			}
			bytes_consumed += bytes_now;
			nums_read += nums_now;
			auryn_vector_float_set(iter->second, i, temp );
		}

		for ( int k = 0 ; k < pretraces.size() ; k++ ) {
			for ( int l = 0 ; l < get_locked_range() ; ++l ) {
				if ( ( nums_now = sscanf( buf + bytes_consumed, "%f%n", & temp, & bytes_now ) ) <= 0 )
				{
					// error handling
					logger->msg("Expected additional fields for pretrace values. Corrupted nstate file? Aborting.",ERROR);
					return;
				}
				bytes_consumed += bytes_now;
				nums_read += nums_now;
				NeuronID t = get_locked_range()*(i)+l;
				if ( t<get_size() )
					pretraces[k]->set(t,temp);

				// cout << temp << endl;
			}
		}

		for ( int k = 0 ; k < posttraces.size() ; k++ ) {
			if ( ( nums_now = sscanf( buf + bytes_consumed, "%f%n", & temp, & bytes_now ) ) <= 0 )
			{
				// error handling
				logger->msg("Expected additional fields for posttrace values. Corrupted nstate file? Aborting.",ERROR);
				return;
			}
			bytes_consumed += bytes_now;
			nums_read += nums_now;
			posttraces[k]->set(i,temp);
		}


		// check if we read all the values on that line
		if ( ( nums_now = sscanf( buf + bytes_consumed, "%f%n", & temp, & bytes_now ) ) > 0 )
		{
			// error handling
			logger->msg("There were unprocessed values in nstatefile.",WARNING);
		}
}
Example #6
0
void SpikingGroup::randomize_state_vector_gauss(string state_vector_name, AurynState mean, AurynState sigma, int seed)
{
	boost::mt19937 ng_gen(seed+communicator->rank()); // produces same series every time 
	boost::normal_distribution<> dist((double)mean, (double)sigma);
	boost::variate_generator<boost::mt19937&, boost::normal_distribution<> > die(ng_gen, dist);
	AurynState rv;

	auryn_vector_float * vec = get_state_vector(state_vector_name); 


	for ( AurynLong i = 0 ; i<get_rank_size() ; ++i ) {
		rv = die();
		auryn_vector_float_set( vec, i, rv );
	}

}
Example #7
0
void TIFGroup::set_bg_current(NeuronID i, AurynFloat current) {
	if ( localrank(i) )
		auryn_vector_float_set ( bg_current , global2rank(i) , current ) ;
}