Created
October 5, 2019 18:11
-
-
Save anupamchugh/26586328d03eff59c4e7a63247376626 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let modelConfig = MLModelConfiguration() | |
modelConfig.computeUnits = .cpuAndGPU | |
let updateTask = try MLUpdateTask(forModelAt: modelURL, trainingData: batchProvider(), configuration: modelConfig, | |
progressHandlers: MLUpdateProgressHandlers(forEvents: [.trainingBegin,.epochEnd], | |
progressHandler: { (contextProgress) in | |
print(contextProgress.event) | |
}) { (finalContext) in | |
if finalContext.task.error?.localizedDescription == nil | |
{ | |
let fileManager = FileManager.default | |
do { | |
let documentDirectory = try fileManager.url(for: .documentDirectory, in: .userDomainMask, appropriateFor:nil, create:true) | |
let fileURL = documentDirectory.appendingPathComponent("CatDog.mlmodelc") | |
try finalContext.model.write(to: fileURL) | |
self.updatableModel = self.loadModel(url: fileURL) | |
} catch(let error) { | |
print("error is \(error.localizedDescription)") | |
} | |
} | |
}) | |
updateTask.resume() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment