<commit_before>#ifndef NN_RELU_HPP
#define NN_RELU_HPP

#include <math.h>
#include "map.hpp"

namespace nnlib
{

/// Rectified linear activation function.
template <typename T = double>
class ReLU : public Map<T>
{
public:
	ReLU(T leak = 0.1) :
		m_leak(leak)
	{}
	
	ReLU(const ReLU &module) :
		m_leak(module.m_leak)
	{}
	
	ReLU(const Serialized &node) :
		m_leak(node.get<T>("leak"))
	{}
	
	ReLU &operator=(const ReLU &module)
	{
		m_leak = module.m_leak;
		return *this;
	}
	
	/// Save to a serialized node.
	virtual void save(Serialized &node) const override
	{
		Map<T>::save(node);
		node.set("leak", m_leak);
	}
	
	/// Get the "leak" for this ReLU. 0 if non-leaky.
	T leak() const
	{
		return m_leak;
	}
	<commit_msg>Added an assert to ReLU constructor.<commit_after>#ifndef NN_RELU_HPP
#define NN_RELU_HPP

#include <math.h>
#include "map.hpp"

namespace nnlib
{

/// Rectified linear activation function.
template <typename T = double>
class ReLU : public Map<T>
{
public:
	ReLU(T leak = 0.1) :
		m_leak(leak)
	{
		NNAssertGreaterThanOrEquals(leak, 0, "Expected positive leak!");
		NNAssertLessThan(leak, 1, "Expected leak to be a percentage!");
	}
	
	ReLU(const ReLU &module) :
		m_leak(module.m_leak)
	{}
	
	ReLU(const Serialized &node) :
		m_leak(node.get<T>("leak"))
	{}
	
	ReLU &operator=(const ReLU &module)
	{
		m_leak = module.m_leak;
		return *this;
	}
	
	/// Save to a serialized node.
	virtual void save(Serialized &node) const override
	{
		Map<T>::save(node);
		node.set("leak", m_leak);
	}
	
	/// Get the "leak" for this ReLU. 0 if non-leaky.
	T leak() const
	{
		return m_leak;
	}
	
{'fraction_non_alphanumeric': 0.14383561643835616, 'fraction_numerical': 0.0049813200498132005, 'mean_word_length': 3.6445086705202314, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, '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': '5416739', 'n_tokens_mistral': 721, 'n_tokens_neox': 656, 'n_words': 160}