<commit_before>import Foundation
import Metal
import MetalKit
import MetalPerformanceShaders
import Forge

/**
  The neural network from the paper "MobileNets: Efficient Convolutional Neural
  Networks for Mobile Vision Applications" https://arxiv.org/abs/1704.04861v1

  **NOTE:** This is currently using random parameters; the network *hasn't been 
  trained on anything yet*, so the predictions don't make any sense at all! 
  I just wanted to see how fast/slow this network architecture is on iPhone.
*/
class MobileNet: NeuralNetwork {
  typealias Prediction = (labelIndex: Int, probability: Float)

  let classes: Int
  let model: Model

  /**
    Creates a new MobileNet object.
    
    - Parameters:
      - widthMultiplier: Shrinks the number of channels. This is a value in the
        range (0, 1]. Default is 1, which starts the network with 32 channels.
        (This hyperparameter is called "alpha" in the paper.)
      - resolutionMultiplier: Shrink the spatial dimensions of the input image.
        This is a value between (0, 1]. Default is 1, which resizes to 224x224
        pixels. (The paper calls this hyperparameter "rho".)
      - shallow: Whether to exclude the group of 5 conv layers in the middle.
      - classes: The number of classes in the softmax.
  */
  public init(device: MTLDevice,
              widthMultiplier: Float = 1,
              resolutionMultiplier: Float = 1,
              shallow: Bool = false,
              classes: Int = 1000,<commit_msg>:fire: :fire: :fire:<commit_after>import Foundation
import Metal
import MetalKit
import MetalPerformanceShaders
import Forge

/**
  The neural network from the paper "MobileNets: Efficient Convolutional Neural
  Networks for Mobile Vision Applications" https://arxiv.org/abs/1704.04861v1
*/
class MobileNet: NeuralNetwork {
  typealias Prediction = (labelIndex: Int, probability: Float)

  let classes: Int
  let model: Model

  /**
    Creates a new MobileNet object.
    
    - Parameters:
      - widthMultiplier: Shrinks the number of channels. This is a value in the
        range (0, 1]. Default is 1, which starts the network with 32 channels.
        (This hyperparameter is called "alpha" in the paper.)
      - resolutionMultiplier: Shrink the spatial dimensions of the input image.
        This is a value between (0, 1]. Default is 1, which resizes to 224x224
        pixels. (The paper calls this hyperparameter "rho".)
      - shallow: Whether to exclude the group of 5 conv layers in the middle.
      - classes: The number of classes in the softmax.
  */
  public init(device: MTLDevice,
              widthMultiplier: Float = 1,
              resolutionMultiplier: Float = 1,
              shallow: Bool = false,
              classes: Int = 1000,
{'fraction_non_alphanumeric': 0.06891548784911135, 'fraction_numerical': 0.022488211824446862, 'mean_word_length': 2.879043600562588, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, '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': '2642141', 'n_tokens_mistral': 786, 'n_tokens_neox': 728, 'n_words': 330}