<commit_before>#define BOOST_TEST_MODULE TestSoftmaxLossLayer
#include <boost/test/unit_test.hpp>

#include <neu/basic_type.hpp>
#include <neu/activation_func/softmax_loss.hpp>
#include <neu/activation_layer.hpp>

#include <neu/vector_io.hpp>

#include "check_macros.hpp"
#include "context_setup.hpp"

BOOST_AUTO_TEST_CASE(forward) {
	auto input_dim = 2u;
	auto output_dim = input_dim;
	auto batch_size = 4u;

	std::vector<neu::cpu_vector> cpu_input = {
		{0.f, 0.f}, {1.f, 0.f}, {0.f, 1.f}, {1.f, 1.f}
	};
	std::vector<neu::cpu_vector> cpu_teach = {
		{0.f, 0.f}, {1.f, 0.f}, {0.f, 1.f}, {1.f, 1.f}
	};

	neu::gpu_vector input;
	for(auto const& cpui : cpu_input) {
		input.insert(input.end(), cpui.begin(), cpui.end());
	}
	neu::gpu_vector teach;
	for(auto const& cput : cpu_teach) {
		teach.insert(teach.end(), cput.begin(), cput.end());
	}

	auto ac_param = neu::activation_layer_parameter()
		.input_dim(input_dim).batch_size(batch_size)
		.output_dim(output_dim);

	auto ac = neu::make_activation_layer(ac_param,
		neu::softmax_loss(input_dim, batch_size));

	neu::gpu_vector output(output_dim*batch_size);
	ac.test_forward(input, output);
	neu::print(output);
	ac.backward(output, input);
	neu::print(input);
	//TODO
}

BOOST_AUTO_TEST_SUITE_END()<commit_msg>add test_softmax_loss_layer<commit_after>#define BOOST_TEST_MODULE TestSoftmaxLossLayer
#include <boost/test/unit_test.hpp>

#include <neu/basic_type.hpp>
#include <neu/activation_func/softmax_loss.hpp>
#include <neu/activation_layer.hpp>

#include <neu/vector_io.hpp>

#include "check_macros.hpp"
#include "context_setup.hpp"

BOOST_AUTO_TEST_CASE(forward) {
	auto input_dim = 2u;
	auto output_dim = input_dim;
	auto batch_size = 4u;

	std::vector<neu::cpu_vector> cpu_input = {
		{0.f, 0.f}, {1.f, 0.f}, {0.f, 1.f}, {1.f, 1.f}
	};
	std::vector<neu::cpu_vector> cpu_teach = {
		{0.f, 0.f}, {1.f, 0.f}, {0.f, 1.f}, {1.f, 1.f}
	};

	neu::gpu_vector input;
	for(auto const& cpui : cpu_input) {
		input.insert(input.end(), cpui.begin(), cpui.end());
	}
	neu::gpu_vector teach;
	for(auto const& cput : cpu_teach) {
		teach.insert(teach.end(), cput.begin(), cput.end());
	}

	auto ac_param = neu::activation_layer_parameter()
		.input_dim(input_dim).batch_size(batch_size)
		.output_dim(output_dim);

	auto ac = neu::make_activation_layer(ac_param,
		neu::softmax_loss(input_dim, batch_size));

	neu::gpu_vector output(output_dim*batch_size, context);
	ac.test_forward(batch_size, input, output, queue);
	neu::print(output);
	ac.backward(output, input, queue);
	neu::print(input);
	//TODO
}

BOOST_AUTO_TEST_SUITE_END()
{'fraction_non_alphanumeric': 0.17215975184179916, 'fraction_numerical': 0.013958898797983715, 'mean_word_length': 5.581632653061225, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6591591', 'n_tokens_mistral': 1151, 'n_tokens_neox': 1094, 'n_words': 174}