Upgrade to Pro — share decks privately, control downloads, hide ads and more …

CoreML3のオンデバイストレーニングでつくる母音推定

naru-jpn
January 25, 2020

 CoreML3のオンデバイストレーニングでつくる母音推定

naru-jpn

January 25, 2020
Tweet

More Decks by naru-jpn

Other Decks in Technology

Transcript

  1. લॲཧ Preprocessing ֶश / ਪ࿦ Training / Inference Ի੠σʔλ Audio

    let captureSession = AVCaptureSession() … captureSession.startSession()
  2. લॲཧ Preprocessing ֶश / ਪ࿦ Training / Inference Ի੠σʔλ Audio

    ϑʔϦΤม׵ Fourier Transformation ϝϧϑΟϧλόϯΫ Mel Filter Bank ཭ࢄίαΠϯม׵ Discrete Cosine Transformation
  3. ϑʔϦΤม׵ Fourier Transformation (ϩά)ϝϧϑΟϧλόϯΫ (Log) Mel Filter Bank ཭ࢄίαΠϯม׵ Discrete

    Cosine Transformation Import Accelerate // ԻΛप೾਺͝ͱʹ෼ղ vDSP_fft_zrip(fftsetup, … // ਓ͕ฉ͖෼͚΍͍͢௿ԻΛΑΓৄࡉʹ vDSP_mmul(melFilerBank, … // ΑΓগͳ͍σʔλ਺Ͱදݱ vDSP_DCT_Execute(dctsetup, …
  4. ϑʔϦΤม׵ Fourier Transformation (ϩά)ϝϧϑΟϧλόϯΫ (Log) Mel Filter Bank ཭ࢄίαΠϯม׵ Discrete

    Cosine Transformation Import Accelerate // ԻΛप೾਺͝ͱʹ෼ղ vDSP_fft_zrip(fftsetup, … // ਓ͕ฉ͖෼͚΍͍͢௿ԻΛΑΓৄࡉʹ vDSP_mmul(melFilerBank, … // ΑΓগͳ͍σʔλ਺Ͱදݱ vDSP_DCT_Execute(dctsetup, … 1024ݸͷσʔλ 16ݸͷσʔλ ~25μs
  5. લॲཧ Preprocessing ֶश / ਪ࿦ Training / Inference Ի੠σʔλ Audio

    https://github.com/apple/coremltools/blob/master/examples/updatable_models/updatable_nearest_neighbor_classifier.ipynb apple/coremltools updatable_nearest_neighbor_classifier.ipynb Jupyter notebook ্Ͱkۙ๣๏Λར༻ͯ͠෼ ྨΛ͢ΔϞσϧΛ࡞੒͢Δαϯϓϧ
  6. લॲཧ Preprocessing ֶश / ਪ࿦ Training / Inference Ի੠σʔλ Audio

    https://github.com/apple/coremltools/blob/master/examples/updatable_models/updatable_nearest_neighbor_classifier.ipynb // ֶशʹ࢖͏σʔλͷ४උ let inputValue = snapshot.featureValue let outputValue = MLFeatureValue( string: snapshot.vowel.identifier ) let dataPointFeatures: [String: MLFeatureValue] = [ "input": inputValue, "label": outputValue ] let provider = try! MLDictionaryFeatureProvider( dictionary: dataPointFeatures )
  7. લॲཧ Preprocessing ֶश / ਪ࿦ Training / Inference Ի੠σʔλ Audio

    https://github.com/apple/coremltools/blob/master/examples/updatable_models/updatable_nearest_neighbor_classifier.ipynb // ֶशͷ࣮ߦ let batchProvider = MLArrayBatchProvider( array: featureProviders ) let updateTask = try! MLUpdateTask( forModelAt: UpdatableKNN.urlOfModelInThisBundle, trainingData: batchProvider, configuration: nil, completionHandler: completion ) updateTask.resume()
  8. લॲཧ Preprocessing ֶश / ਪ࿦ Training / Inference Ի੠σʔλ Audio

    https://github.com/apple/coremltools/blob/master/examples/updatable_models/updatable_nearest_neighbor_classifier.ipynb // ਪ࿦ͷ࣮ߦ let inputs = snapshots.compactMap({ $0.featureValue.multiArrayValue }).map({ UpdatableKNNInput(input: $0) }) let model = try! UpdatableKNN(contentsOf: updatedModelUrl) // ฼Ի͝ͱͷ֬཰͕ग़ྗͱͯ͠ฦͬͯ͘Δ let outputs = try model.predictions(inputs: inputs) 100~200μs