コード例 #1
0
void NeuralNetwork::RTRL_update_gradients()
{
	// for every neuron
	for (unsigned int k = m_num_inputs; k < m_neurons.size(); k++)
	{
		// for all possible connections
		for (unsigned int i = m_num_inputs; i < m_neurons.size(); i++)
			// to
			for (unsigned int j = 0; j < m_neurons.size(); j++) // from
			{
				int t_idx = ConnectionExists(i, j);
				if (t_idx != -1)
				{
					//double t_derivative = unsigned_sigmoid_derivative( m_neurons[k].m_activation );
					double t_derivative = 0;
					if (m_neurons[k].m_activation_function_type
							== NEAT::UNSIGNED_SIGMOID)
					{
						t_derivative = unsigned_sigmoid_derivative(
								m_neurons[k].m_activation);
					}
					else if (m_neurons[k].m_activation_function_type
							== NEAT::TANH)
					{
						t_derivative = tanh_derivative(
								m_neurons[k].m_activation);
					}

					double t_sum = 0;
					// calculate the other sum
					for (unsigned int l = 0; l < m_neurons.size(); l++)
					{
						int t_l_idx = ConnectionExists(k, l);
						if (t_l_idx != -1)
						{
							t_sum += m_connections[t_l_idx].m_weight
									* m_neurons[l].m_sensitivity_matrix[i][j];
						}
					}

					if (i == k)
					{
						t_sum += m_neurons[j].m_activation;
					}
					m_neurons[k].m_sensitivity_matrix[i][j] = t_derivative
							* t_sum;
				}
				else
				{
					m_neurons[k].m_sensitivity_matrix[i][j] = 0;
				}
			}

	}

}
コード例 #2
0
// Выход из чата.
void OnUserDisconnect(BYTE *InBuffer) {
	String name;

	try {
		//name
		GetStreamString(&InBuffer, &name);

		RemoveUserFromChannels(name);

		// Проверяем, является ли пользователь виртуальным. Если да, то проверяем список отслеживаний каналов.
		LogicalConnections::iterator connection = FindConnectionByUser(name);
		if (ConnectionExists(connection)) {
			UnsetConnectionUser(connection);
		}

		RemoveOnlineUser(name);

		MapList params;
		params.insert(pair<String, String>("user", name));

		String json_object = SetParametersObject(params);
		SendNotification("user_disconnect", json_object, GetConnectionsRef(true));
	} catch (Exception *E) {
		throw(Format(e_user_disconnect, ARRAYOFCONST((E->Message))));
	}
}
コード例 #3
0
ファイル: Add.cpp プロジェクト: tinyserver/swish
/** Display dialog to get connection info from user. */
void Add::operator()(const com_ptr<IDataObject>&, const com_ptr<IBindCtx>&)
const
{
    host_info info = add_host(m_hwnd);

    if (ConnectionExists(info.name))
        BOOST_THROW_EXCEPTION(com_error(E_FAIL));

    AddConnectionToRegistry(
        info.name, info.host, info.port, info.user, info.path);

    notify_shell(m_folder_pidl);
}
コード例 #4
0
// please pay attention. notice here only one output is assumed
void NeuralNetwork::RTRL_update_error(double a_target)
{
	// add to total error
	m_total_error = (a_target - Output()[0]);
	// adjust each weight
	for (unsigned int i = 0; i < m_neurons.size(); i++) // to
	{
		for (unsigned int j = 0; j < m_neurons.size(); j++) // from
		{
			int t_idx = ConnectionExists(i, j);
			if (t_idx != -1)
			{
				// we know the first output's index is m_num_inputs
				double t_delta = m_total_error
						* m_neurons[m_num_inputs].m_sensitivity_matrix[i][j];
				m_total_weight_change[t_idx] += t_delta * LEARNING_RATE;
			}
		}
	}
}
コード例 #5
0
// Инициализация соединения.
String meth::CheckConnectionID(String conn_id) {
	return (ConnectionExists(conn_id)) ? "true" : "false";
}