<commit_before>﻿using System;
using System.Collections.Generic;
using System.Linq;
using ConvNetSharp.Flow.Ops;
using ConvNetSharp.Volume;

namespace ConvNetSharp.Flow
{
    public class ConvNetSharp<T> where T : struct, IEquatable<T>, IFormattable
    {
        public static readonly T Zero;

        public static readonly T One;

        private static readonly Lazy<ConvNetSharp<T>> Lazy = new Lazy<ConvNetSharp<T>>(() => new ConvNetSharp<T>());

        private readonly Stack<string> _scopes = new Stack<string>();

        static ConvNetSharp()
        {
            Zero = default(T);

            if (typeof(T) == typeof(double))
            {
                One = (T) (ValueType) 1.0;
            }
            else if (typeof(T) == typeof(float))
            {
                One = (T) (ValueType) 1.0f;
            }
        }

        public static ConvNetSharp<T> Instance => Lazy.Value;

        public Const<T> Const(Volume<T> v, string name)
        {
            return new Const<T>(v, name);
        }

        public Op<T> Conv(Op<T> x, int width, int height, int filterCount, int stride = 1, int pad = 0)
        {
            return new Convolution<T>(x, width, height, filterCount, stride, pad);
        }

        public Op<T> CrossEntropyLoss(Op<T> x, Op<T> y)
        {
            return new SoftMaxCrossEntropy<T>(x, y);
        }

        public Op<T> Exp(Op<T> x)
        {
            return new Exp<T>(x);
        }

        public Op<T> Log(Op<T> x)
        {
            return new Log<T>(x);
        }

        public PlaceHolder<T> PlaceHolder(string name)
        {
            return new PlaceHolder<T>(name);
        }

        public void RegisterScope(string name)
        {
            this._scopes.Push(name);
        }

        public void ReleaseScope(string name)
        {
            var popped = this._scopes.Pop();

            if (popped != name)
            {
                throw new ArgumentException($"Released scope should be '{popped} 'but was '{name}'");
            }
        }

        public Op<T> Relu(Op<T> x)
        {
            return new Activation<T>(x, ActivationType.Relu);
        }

        public Scope<T> Scope(string name)<commit_msg>Pool op<commit_after>﻿using System;
using System.Collections.Generic;
using System.Linq;
using ConvNetSharp.Flow.Ops;
using ConvNetSharp.Volume;

namespace ConvNetSharp.Flow
{
    public class ConvNetSharp<T> where T : struct, IEquatable<T>, IFormattable
    {
        public static readonly T Zero;

        public static readonly T One;

        private static readonly Lazy<ConvNetSharp<T>> Lazy = new Lazy<ConvNetSharp<T>>(() => new ConvNetSharp<T>());

        private readonly Stack<string> _scopes = new Stack<string>();

        static ConvNetSharp()
        {
            Zero = default(T);

            if (typeof(T) == typeof(double))
            {
                One = (T)(ValueType)1.0;
            }
            else if (typeof(T) == typeof(float))
            {
                One = (T)(ValueType)1.0f;
            }
        }

        public static ConvNetSharp<T> Instance => Lazy.Value;

        public Const<T> Const(Volume<T> v, string name)
        {
            return new Const<T>(v, name);
        }

        public Op<T> Conv(Op<T> x, int width, int height, int filterCount, int stride = 1, int pad = 0)
        {
            return new Convolution<T>(x, width, height, filterCount, stride, pad);
        }

        public Op<T> CrossEntropyLoss(Op<T> x, Op<T> y)
        {
            return new SoftMaxCrossEntropy<T>(x, y);
        }

        public Op<T> Exp(Op<T> x)
        {
            return new Exp<T>(x);
        }

        public Op<T> Log(Op<T> x)
        {
            return new Log<T>(x);
        }

        public PlaceHolder<T> PlaceHolder(string name)
        {
            return new PlaceHolder<T>(name);
        }

        public Op<T> Pool(Op<T> x, int width, int height, int horizontalPad, int verticalPad, int horizontalStride, int verticalStride)
        {
            return new Pool<T>(x, width, height, horizontalPad, verticalPad, horizontalStride, verticalStride);
        }

        public void RegisterScope(string name)
        {
            this._scopes.Push(name);
        }

        public void ReleaseScope(string name)
        {
            var popped = this._scopes.Pop();

            if (popped != name)
            {
                throw new ArgumentException($"Released scope should be '{popped} 'but was '{name}'");
            }
        }

        public Op<T> Relu(Op<T> x)
        {
            return new Activation<T>(x, ActivationType.Relu);
        }

        public Scope<T> Scope(string name)
{'fraction_non_alphanumeric': 0.1141455088542778, 'fraction_numerical': 0.002560273095796885, 'mean_word_length': 1.7641509433962264, 'pattern_counts': {'":': 0, '<': 70, '<?xml version=': 0, '>': 74, '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': '1351215', 'n_tokens_mistral': 1450, 'n_tokens_neox': 1363, 'n_words': 363}