Machine Learning

RSS for tag

Create intelligent features and enable new experiences for your apps by leveraging powerful on-device machine learning.

Posts under Machine Learning tag

200 Posts

Post

Replies

Boosts

Views

Activity

Max number of training image data for CreateML?
Hello Everyone, I am trying to train a hand pose classifier. But I stumble upon the problem where if I give training data above certain number (i.e. ~4000 images). Is it a limit imposed by Apple? because I even tried to reduce the size of images and even dimensions but it always gives me error while training whenever I give training data above certain number. Has anyone else stumbled upon this problem?if so, is there any work around for any number of data can be given to CreateML? Thanks
1
2
1.4k
Mar ’23
How to use YOLOv3 from applescript
Hello. I would like to compile the YOLOv3.mlmodel for object detection as a framework and call it from applescript to use it, but I do not know how. The flow I am imagining is as follows Import "YOLOv3.mlmodel" on xcode and create a framework. Load the created framework with applescript's use statement and execute it. Please let me know if you know anything about this.
1
0
918
Mar ’23
MacOS with external GPU for machine learning
Greetings! I have a MacBook Pro (2018) running macOS Monterey and was wondering if it could be repurposed for machine learning work. I have a Razer Core X, which would enable me to use AMD Radeon 6900 XT as a eGPU supported configuration. Before doing any shopping, my question is whether the usage of TensorFlow is feasible with this setup. I am aware of tensorflow-metal, but if I understand correctly, only natively supported Mac GPUs can be used with it (not eGPUs)? PlaidML is also an option, but it still not clear which external GPUs are supported. Any guidance on this topic will be appreciated.
1
0
1.8k
Mar ’23
Xcode Cannot generate model encryption key
hello, When I used xcode to generate the model encryption key, an error was reported, the error was 'Failed to Generate Encryption Key and Sign in with you Apple ID in the Apple ID pane in System Preferences and retry '.But I have logged in my apple id in the system preferences, and this error still occurs.I reinstalled xcode and re-logged in to my apple id. This error still exists. Xcode Version 12.4 macOS Catalina 10.15.7 thanks
27
5
8.1k
Mar ’23
Not sure if the cpu percentage is normal
The previous question haven't been solved. I send it again. when my video neural network model was running on iphone11, the cpu occupation reached to 31%, is it normal? I am not sure if the value 31% has a serious impact on the other app. So that I would ask for your advice. Previously, I originally expected to lower the cpu percentage by reducing the model op. when I put a model with only 6 biliear_interpolation ops into coreml, the cpu percentage is 20%(equal on cpu, cpuandgpu&all), so I consider if the only coreML scheduling occupy the 20% cpu?
0
0
729
Mar ’23
Problem mit text classifier model
Hi, ich habe nach folgender Anleitung versucht ein Text classifier model zu machen.Allerdings scheitert dies daran, das die evaluation() Funktion nicht funktioniert.Den Error den ich (in SwiftPlayground) bekomme ist: No exact matches in call to instance method 'evaluation' Hier ist der Code, den ich verwende: if #available(iOSApplicationExtension 15.0, *) {         let data = try! MLDataTable(contentsOf:  fileLiteral(resourceName: "TestData.json"))          let (trainingData, testingData) = data.randomSplit(by: 0.8, seed: 5)                  let sentimentClassifier = try! MLTextClassifier(trainingData: trainingData,                                                        textColumn: "text",                                                        labelColumn: "label")         // Training accuracy as a percentage         let trainingAccuracy = (1.0 - sentimentClassifier.trainingMetrics.classificationError) * 100         // Validation accuracy as a percentage         let validationAccuracy = (1.0 - sentimentClassifier.validationMetrics.classificationError) * 100         let evaluationMetrics = sentimentClassifier.evaluation(on: testingData)//Error hier         let evaluationAccuracy = (1.0 - evaluationMetrics.classificationError) * 100                  let metadata = MLModelMetadata(author: "No One",                                        shortDescription: "A model trained to classify movie review sentiment",                                        version: "1.0")         try! sentimentClassifier.write(to: URL(fileURLWithPath: Bundle.main.path(forResource: "MODEL", ofType: "mlmodel")!),                                       metadata: metadata)     } else {         print("dein Gerät erfüllt nicht die Bedingungen für dieses Programm")     } vielen Dank im Voraus (:
1
0
2.0k
Mar ’23
tf.einsum runs on CPU only with tensorflow-macos and tensorflow-metal
I found out that tf.einsum is extremely slow when running on Apple Silicone. And it's due to tf.einsum being placed on CPU instead of GPU. This causes very low GPU utilization and slowness of the operation itself. I tried forcing it on GPU, but does not work. It can be reproduced with following code that logs device placement for tf.einsum. import tensorflow as tf # https://www.tensorflow.org/guide/gpu#logging_device_placement tf.debugging.set_log_device_placement(True) print(tf.__version__) print("Num GPUs Available: ", len(tf.config.list_physical_devices('GPU'))) B=1000 S=200 N=16 K=64 a = tf.random.uniform(shape=[B,N,S,K], minval=0.0, maxval=100.0, dtype=float) b = tf.random.uniform(shape=[B,N,S,K], minval=0.0, maxval=100.0, dtype=float) tf.einsum('BNSK,BNTK->BNTS', a,b) # Notice in the output Einsum is placed on CPU. Output: Executing op Einsum in device /job:localhost/replica:0/task:0/device:CPU:0 2023-03-08 16:44:01.119144: I tensorflow/core/common_runtime/placer.cc:114] inputs_0: (_Arg): /job:localhost/replica:0/task:0/device:CPU:0 2023-03-08 16:44:01.119182: I tensorflow/core/common_runtime/placer.cc:114] inputs_1: (_Arg): /job:localhost/replica:0/task:0/device:CPU:0 2023-03-08 16:44:01.119191: I tensorflow/core/common_runtime/placer.cc:114] Einsum: (Einsum): /job:localhost/replica:0/task:0/device:CPU:0 2023-03-08 16:44:01.119197: I tensorflow/core/common_runtime/placer.cc:114] output_RetVal: (_Retval): /job:localhost/replica:0/task:0/device:CPU:0 If I use tf.matmul, then everything happen on GPU which is what I want. With this limitation I basically have to convert all the code that uses tf.einsum to using tf.matmul and is very inconvenient. Has anyone noticed the same problem? What's your solution?
0
0
1k
Mar ’23
Cannot import Tensorflow Apple M1
I'm trying to use tensorflow, but I can't import it. I followed the steps on the Apple website to download and install Tensorflow, and everything appears to be ok, but when I try to import tensorflow, I get some errors. What should I do? Errors: TypeError: Unable to convert function return value to a Python type! The signature was () -> handle RuntimeError: module compiled against API version 0x10 but this version of numpy is 0xf RuntimeError: module compiled against API version 0x10 but this version of numpy is 0xf ImportError: numpy.core._multiarray_umath failed to import ImportError: numpy.core.umath failed to import what I did: conda create --name myenv python conda activate myenv conda install -c apple tensorflow-deps python -m pip install tensorflow-macos python -m pip install tensorflow-metal conda list: Thanks, Ed
3
0
3.2k
Mar ’23
Detecting malware through Machine Learning
Hello, I wanted to hear some opinions on this problem I want to tackle. Currently at my job we have an Endpoint Security sysext app (swift) deployed on 10k+ macs and we are using a custom rule engine we developed to run some rules on the events received by the app. These rules are downloaded by the app. This works great but we wanted to dive into the world of ML and try to use it to detect more complex malware that may be more difficult to detect using rules. We thought of two options to approach this: Periodically collect events from all macs and send them to an api to be stored somewhere and perform the training in the cloud. Somehow, maybe using the ML frameworks provided in Swift, train the model IN the device rather than in the cloud. I know this is a very broad question but I just wanted to hear some suggestions. Thanks in advance.
2
0
1.6k
Mar ’23
ML ANE Model unloaded on first call to predict
Hi, I am trying to take advantage of my device ANE. I have created a model from torch using coremltools and adapted it until xcode model performance preview indicates it will run on my device ANE. But when i profile my integration into my app, i can see from the com.apple.ane logs the model has been loaded on device: Timestamp Type Process Category Message 00:00.905.087 Debug MLBench (11135) client doLoadModel:options:qos:error:: model[0x2804500c0] : success=1 : progamHandle=10 000 241 581 886: intermediateBufferHandle=10 000 242 143 532 : queueDepth=32 :err= but when i call predict on my model, the ANE is unloaded and the prediction run on CPU: Timestamp Type Process Category Message 00:00.996.015 Debug MLBench (11135) client doUnloadModel:options:qos:error:: model[0x2804500c0]=_ANEModel: { modelURL=file:///var/mobile/Containers/Data/Application/0A9F356B-B8C7-4B86-90A5-6812EF48CC94/tmp/math_custom_trans_decoder_seg_0DB63A47-E84E-4887-A606-BC9986B2C662.mlmodelc/ : key={"isegment":0,"inputs":{"extras":{"shape":[2,1,1,1,1]},"memory":{"shape":[128,5,1,1,1]},"proj_key_seg_in":{"shape":[128,39,1,1,1]},"state_in_k":{"shape":[32,1,1,20,2]},"tgt":{"shape":[5,1,1,1,1]},"state_in_v":{"shape":[32,1,1,20,2]},"pos_enc":{"shape":[128,1,1,1,1]}},"outputs":{"attn_seg":{"shape":[1,5,1,4,1]},"state_out_v":{"shape":[32,2,1,20,2]},"output":{"shape":[292,5,1,1,1]},"state_out_k":{"shape":[32,2,1,20,2]},"extras_tmp":{"shape":[2,1,1,1,1]},"proj_key_seg_in_tmp":{"shape":[128,39,1,1,1]},"attn":{"shape":[1,1,1,5,2]},"proj_key_seg":{"shape":[128,1,1,20,1]}}} : string_id=0x70ac000000015257 : program=_ANEProgramForEvaluation: { programHandle=10000241581886 : intermediateBufferHandle=10000242143532 : queueDepth=32 } : state=3 : programHandle=10000241581886 : intermediateBufferHandle=10000242143532 : queueDepth=32 : attr=... : perfStatsMask=0}  i dont see any obvious error messages in com.apple.ane, com.apple.coreml or com.apple.espresso. where/what should i look for to understand what is going on? and in particular why the ANE model was unloaded? Thank you
2
0
2.1k
Feb ’23
PyTorch Training on iOS Devices
Is there any way to train PyTorch models directly on-device on an iPhone via the GPU? PyTorch Mobile docs seems to be completely focused on inference only, as do the iOS app examples (https://github.com/pytorch/ios-demo-app). I did find this article about using MPS backend on Macs (https://developer.apple.com/metal/pytorch/), but not sure if this is at all viable for iOS devices. There's also this prototype article about using iOS GPU for PyTorch mobile (https://pytorch.org/tutorials/prototype/ios_gpu_workflow.html), but it too seems to be focused on inference only. We are attempting to train a large language model on the iPhone 14 and we would like to a) discard intermediate activations and recompute them, and b) manage memory directly to write some intermediate activations to the filesystem and later read them back. We suspect that converting a PyTorch model to CoreML format and using CoreML for training would prevent us from making these low-level modifications, but PyTorch might have the APIs necessary for this. If there's any examples/pointers that anyone can link to that would be great.
1
0
3.5k
Feb ’23
Cannot use XLA accelerator Tensorflow in M1 silicon
I'm trying to use XLA in TensorFlow using jit_compile=True, currently. However, the error looks like it cannot. First of all, I tried simple code as below, import tensorflow as tf @tf.function(jit_compile=True) def operation(a, b): return a * b And, I got an error as below, (base) ***@MacBook-Pro folder % /Users/***/miniforge3/envs/testtf/bin/python /Users/***/workplace/research/folder/subfolder/test/test_jit_compile.py Metal device set to: Apple M1 Pro systemMemory: 32.00 GB maxCacheSize: 10.67 GB 2023-01-11 12:45:18.794439: I tensorflow/core/common_runtime/pluggable_device/pluggable_device_factory.cc:306] Could not identify NUMA node of platform GPU ID 0, defaulting to 0. Your kernel may not have been built with NUMA support. 2023-01-11 12:45:18.794689: I tensorflow/core/common_runtime/pluggable_device/pluggable_device_factory.cc:272] Created TensorFlow device (/job:localhost/replica:0/task:0/device:GPU:0 with 0 MB memory) -> physical PluggableDevice (device: 0, name: METAL, pci bus id: <undefined>) 2023-01-11 12:45:18.808796: W tensorflow/core/framework/op_kernel.cc:1830] OP_REQUIRES failed at xla_ops.cc:418 : NOT_FOUND: could not find registered platform with id: 0x10c7ba7e0 Traceback (most recent call last): File "/Users/***/workplace/research/folder/subfolder/test/test_jit_compile.py", line 25, in <module> print(operation(3, 4)) File "/Users/***/miniforge3/envs/testtf/lib/python3.8/site-packages/tensorflow/python/util/traceback_utils.py", line 153, in error_handler raise e.with_traceback(filtered_tb) from None File "/Users/***/miniforge3/envs/testtf/lib/python3.8/site-packages/tensorflow/python/eager/execute.py", line 52, in quick_execute tensors = pywrap_tfe.TFE_Py_Execute(ctx._handle, device_name, op_name, tensorflow.python.framework.errors_impl.NotFoundError: could not find registered platform with id: 0x10c7ba7e0 [Op:__inference_operation_5] This seems like XLA did not register. Would you guide how to use jit_compile=True in this environment? I attached my environment as below also. Package Version ----------------------- --------- absl-py 1.3.0 astunparse 1.6.3 cachetools 5.2.1 certifi 2022.12.7 charset-normalizer 2.1.1 flatbuffers 23.1.4 gast 0.4.0 google-auth 2.16.0 google-auth-oauthlib 0.4.6 google-pasta 0.2.0 grpcio 1.42.0 h5py 3.6.0 idna 3.4 importlib-metadata 6.0.0 keras 2.11.0 libclang 15.0.6.1 Markdown 3.4.1 MarkupSafe 2.1.1 numpy 1.22.3 oauthlib 3.2.2 opt-einsum 3.3.0 packaging 23.0 pip 22.3.1 protobuf 3.19.6 pyasn1 0.4.8 pyasn1-modules 0.2.8 requests 2.28.1 requests-oauthlib 1.3.1 rsa 4.9 setuptools 65.6.3 six 1.16.0 tensorboard 2.11.0 tensorboard-data-server 0.6.1 tensorboard-plugin-wit 1.8.1 tensorflow-estimator 2.11.0 tensorflow-macos 2.11.0 tensorflow-metal 0.7.0 termcolor 2.2.0 typing_extensions 4.4.0 urllib3 1.26.13 Werkzeug 2.2.2 wheel 0.37.1 wrapt 1.14.1 zipp 3.11.0 Thanks.
3
0
2.8k
Jan ’23
How can I construct an MLModelAsset using data from an in-memory representation?
I’m developing a macOS app that uses a proprietary Core ML model, which I need to encrypt. Since Core ML doesn’t support model encryption on macOS, I plan to encrypt the model myself using a symmetric key and decrypt it at runtime. To minimize the possibility of the model being compromised, I’d like to ensure that the decrypted model is only accessible in-memory, not on-disk. So my app will load the encrypted data, decrypt it with CryptoKit, construct an MLModelAsset with the decrypted data, and load that with MLModel.load(MLModelAsset...). The part I’m stuck on is constructing the MLModelAsset. It only has one initializer method: init(specification: Data), where specification is described as “[t]he contents of a .mlmodel as a data blob.” My model is in the .mlpackage format, which is a macOS package (i.e. a directory, not a blob). Attempting to initialize MLModelAsset with the (unencrypted) .mlmodel file stored inside the .mlpackage (under “Data/com.apple.CoreML/model.mlmodel”) throws an error: testLoadingPlainTextModel(): failed: caught error: "Error Domain=com.apple.CoreML Code=0 "compiler error:  Encountered an error while compiling a neural network model: in operation op_7_to_fp16: Cannot interpret @model_path when ModelPath is unset" UserInfo={NSLocalizedDescription=compiler error:  Encountered an error while compiling a neural network model: in operation op_7_to_fp16: Cannot interpret @model_path when ModelPath is unset}" Since .mlpackage stores the model architecture and the weights in separate files, this isn’t unexpected. But I have no idea how to load the .mlpackage (or the corresponding .mlmodelc) as a blob, since they’re both directories and Data(contentsOf:) throws an error if you try to load them. (Note: I’m testing all this without any encryption for the time being—neither the .mlpackage or .mlmodelc is encrypted in my test project.) What am I doing wrong? Is there any way to load an .mlpackage or .mlmodelc package as a blob, for instantiating MLModelAsset? Or is there a different/better way to encrypt Core ML models on macOS? Thanks!
2
0
1.5k
Jan ’23
Core ML: Strong increase in load time with quantisation from 16 to 8 bits
Hi, I have a BERT-large model that has been quantised to 16 bits. According to the performance report, the model takes about 500 ms to load: If I quantise the model further to 8 bits, the loading time increases drastically to almost 2500 ms. That is a fivefold increase: Does anyone have an explanation for this? I would rather have expected a reduction in the loading time, since the model is only half as large due to the further quantisation. I have carried out the measurements several times and always come to the same result. My only idea is that it might be due to the compute precision, which is limited to 16 bits in the CPU, GPU and NPU.
0
0
1.2k
Jan ’23
FullyConnectedNetworkRegressor activation functions
Hi, I am using FullyConnectedNetworkRegressor to build an ML pipeline. The FullyConnectedNetworkConfiguration allows one to specify hiddenUnitCounts for the hidden layers, but I don't see any way to specify or get the activation function for the hidden layers. Is there a way to specify the activation function for the hidden layers? If not, does anyone know what activation function is used for the hidden layers or how they are determined? Thanks, Tom
2
0
1k
Jan ’23
Max number of training image data for CreateML?
Hello Everyone, I am trying to train a hand pose classifier. But I stumble upon the problem where if I give training data above certain number (i.e. ~4000 images). Is it a limit imposed by Apple? because I even tried to reduce the size of images and even dimensions but it always gives me error while training whenever I give training data above certain number. Has anyone else stumbled upon this problem?if so, is there any work around for any number of data can be given to CreateML? Thanks
Replies
1
Boosts
2
Views
1.4k
Activity
Mar ’23
How to use YOLOv3 from applescript
Hello. I would like to compile the YOLOv3.mlmodel for object detection as a framework and call it from applescript to use it, but I do not know how. The flow I am imagining is as follows Import "YOLOv3.mlmodel" on xcode and create a framework. Load the created framework with applescript's use statement and execute it. Please let me know if you know anything about this.
Replies
1
Boosts
0
Views
918
Activity
Mar ’23
MacOS with external GPU for machine learning
Greetings! I have a MacBook Pro (2018) running macOS Monterey and was wondering if it could be repurposed for machine learning work. I have a Razer Core X, which would enable me to use AMD Radeon 6900 XT as a eGPU supported configuration. Before doing any shopping, my question is whether the usage of TensorFlow is feasible with this setup. I am aware of tensorflow-metal, but if I understand correctly, only natively supported Mac GPUs can be used with it (not eGPUs)? PlaidML is also an option, but it still not clear which external GPUs are supported. Any guidance on this topic will be appreciated.
Replies
1
Boosts
0
Views
1.8k
Activity
Mar ’23
Xcode Cannot generate model encryption key
hello, When I used xcode to generate the model encryption key, an error was reported, the error was 'Failed to Generate Encryption Key and Sign in with you Apple ID in the Apple ID pane in System Preferences and retry '.But I have logged in my apple id in the system preferences, and this error still occurs.I reinstalled xcode and re-logged in to my apple id. This error still exists. Xcode Version 12.4 macOS Catalina 10.15.7 thanks
Replies
27
Boosts
5
Views
8.1k
Activity
Mar ’23
Not sure if the cpu percentage is normal
The previous question haven't been solved. I send it again. when my video neural network model was running on iphone11, the cpu occupation reached to 31%, is it normal? I am not sure if the value 31% has a serious impact on the other app. So that I would ask for your advice. Previously, I originally expected to lower the cpu percentage by reducing the model op. when I put a model with only 6 biliear_interpolation ops into coreml, the cpu percentage is 20%(equal on cpu, cpuandgpu&all), so I consider if the only coreML scheduling occupy the 20% cpu?
Replies
0
Boosts
0
Views
729
Activity
Mar ’23
Problem mit text classifier model
Hi, ich habe nach folgender Anleitung versucht ein Text classifier model zu machen.Allerdings scheitert dies daran, das die evaluation() Funktion nicht funktioniert.Den Error den ich (in SwiftPlayground) bekomme ist: No exact matches in call to instance method 'evaluation' Hier ist der Code, den ich verwende: if #available(iOSApplicationExtension 15.0, *) {         let data = try! MLDataTable(contentsOf:  fileLiteral(resourceName: "TestData.json"))          let (trainingData, testingData) = data.randomSplit(by: 0.8, seed: 5)                  let sentimentClassifier = try! MLTextClassifier(trainingData: trainingData,                                                        textColumn: "text",                                                        labelColumn: "label")         // Training accuracy as a percentage         let trainingAccuracy = (1.0 - sentimentClassifier.trainingMetrics.classificationError) * 100         // Validation accuracy as a percentage         let validationAccuracy = (1.0 - sentimentClassifier.validationMetrics.classificationError) * 100         let evaluationMetrics = sentimentClassifier.evaluation(on: testingData)//Error hier         let evaluationAccuracy = (1.0 - evaluationMetrics.classificationError) * 100                  let metadata = MLModelMetadata(author: "No One",                                        shortDescription: "A model trained to classify movie review sentiment",                                        version: "1.0")         try! sentimentClassifier.write(to: URL(fileURLWithPath: Bundle.main.path(forResource: "MODEL", ofType: "mlmodel")!),                                       metadata: metadata)     } else {         print("dein Gerät erfüllt nicht die Bedingungen für dieses Programm")     } vielen Dank im Voraus (:
Replies
1
Boosts
0
Views
2.0k
Activity
Mar ’23
Can HumanBodyActionCounter counts hand action??
I was trying to hand action repetition though HumanBodyActionCounter but seems like its not working. So does HumanBodyActionCounter counts hand action also?
Replies
2
Boosts
0
Views
1.4k
Activity
Mar ’23
tf.einsum runs on CPU only with tensorflow-macos and tensorflow-metal
I found out that tf.einsum is extremely slow when running on Apple Silicone. And it's due to tf.einsum being placed on CPU instead of GPU. This causes very low GPU utilization and slowness of the operation itself. I tried forcing it on GPU, but does not work. It can be reproduced with following code that logs device placement for tf.einsum. import tensorflow as tf # https://www.tensorflow.org/guide/gpu#logging_device_placement tf.debugging.set_log_device_placement(True) print(tf.__version__) print("Num GPUs Available: ", len(tf.config.list_physical_devices('GPU'))) B=1000 S=200 N=16 K=64 a = tf.random.uniform(shape=[B,N,S,K], minval=0.0, maxval=100.0, dtype=float) b = tf.random.uniform(shape=[B,N,S,K], minval=0.0, maxval=100.0, dtype=float) tf.einsum('BNSK,BNTK->BNTS', a,b) # Notice in the output Einsum is placed on CPU. Output: Executing op Einsum in device /job:localhost/replica:0/task:0/device:CPU:0 2023-03-08 16:44:01.119144: I tensorflow/core/common_runtime/placer.cc:114] inputs_0: (_Arg): /job:localhost/replica:0/task:0/device:CPU:0 2023-03-08 16:44:01.119182: I tensorflow/core/common_runtime/placer.cc:114] inputs_1: (_Arg): /job:localhost/replica:0/task:0/device:CPU:0 2023-03-08 16:44:01.119191: I tensorflow/core/common_runtime/placer.cc:114] Einsum: (Einsum): /job:localhost/replica:0/task:0/device:CPU:0 2023-03-08 16:44:01.119197: I tensorflow/core/common_runtime/placer.cc:114] output_RetVal: (_Retval): /job:localhost/replica:0/task:0/device:CPU:0 If I use tf.matmul, then everything happen on GPU which is what I want. With this limitation I basically have to convert all the code that uses tf.einsum to using tf.matmul and is very inconvenient. Has anyone noticed the same problem? What's your solution?
Replies
0
Boosts
0
Views
1k
Activity
Mar ’23
Cannot import Tensorflow Apple M1
I'm trying to use tensorflow, but I can't import it. I followed the steps on the Apple website to download and install Tensorflow, and everything appears to be ok, but when I try to import tensorflow, I get some errors. What should I do? Errors: TypeError: Unable to convert function return value to a Python type! The signature was () -> handle RuntimeError: module compiled against API version 0x10 but this version of numpy is 0xf RuntimeError: module compiled against API version 0x10 but this version of numpy is 0xf ImportError: numpy.core._multiarray_umath failed to import ImportError: numpy.core.umath failed to import what I did: conda create --name myenv python conda activate myenv conda install -c apple tensorflow-deps python -m pip install tensorflow-macos python -m pip install tensorflow-metal conda list: Thanks, Ed
Replies
3
Boosts
0
Views
3.2k
Activity
Mar ’23
Detecting malware through Machine Learning
Hello, I wanted to hear some opinions on this problem I want to tackle. Currently at my job we have an Endpoint Security sysext app (swift) deployed on 10k+ macs and we are using a custom rule engine we developed to run some rules on the events received by the app. These rules are downloaded by the app. This works great but we wanted to dive into the world of ML and try to use it to detect more complex malware that may be more difficult to detect using rules. We thought of two options to approach this: Periodically collect events from all macs and send them to an api to be stored somewhere and perform the training in the cloud. Somehow, maybe using the ML frameworks provided in Swift, train the model IN the device rather than in the cloud. I know this is a very broad question but I just wanted to hear some suggestions. Thanks in advance.
Replies
2
Boosts
0
Views
1.6k
Activity
Mar ’23
Not sure if the cpu percentage is normal
when my video neural network model was running on iphone11, the cpu occupation reached to 31%, is it normal?
Replies
3
Boosts
0
Views
921
Activity
Mar ’23
Cpu occupation of the coreml.
My neural network model has only 6 biliear_interpolation ops running on cpuandgpu, the model's cpu percentage is 20%. And I test my int8model by choosing 3 devices onlyCpu, CpuandGpu, Allunits, the cpu occupation is the same. This is normal? The pecentage is too large?
Replies
0
Boosts
0
Views
611
Activity
Mar ’23
Action & Vision App
Hello- what was the data set size for labeling for this application? Also how did you train new data on new environment. For example, at different times of day, different shadows, different objects, etc…
Replies
0
Boosts
0
Views
835
Activity
Feb ’23
ML ANE Model unloaded on first call to predict
Hi, I am trying to take advantage of my device ANE. I have created a model from torch using coremltools and adapted it until xcode model performance preview indicates it will run on my device ANE. But when i profile my integration into my app, i can see from the com.apple.ane logs the model has been loaded on device: Timestamp Type Process Category Message 00:00.905.087 Debug MLBench (11135) client doLoadModel:options:qos:error:: model[0x2804500c0] : success=1 : progamHandle=10 000 241 581 886: intermediateBufferHandle=10 000 242 143 532 : queueDepth=32 :err= but when i call predict on my model, the ANE is unloaded and the prediction run on CPU: Timestamp Type Process Category Message 00:00.996.015 Debug MLBench (11135) client doUnloadModel:options:qos:error:: model[0x2804500c0]=_ANEModel: { modelURL=file:///var/mobile/Containers/Data/Application/0A9F356B-B8C7-4B86-90A5-6812EF48CC94/tmp/math_custom_trans_decoder_seg_0DB63A47-E84E-4887-A606-BC9986B2C662.mlmodelc/ : key={"isegment":0,"inputs":{"extras":{"shape":[2,1,1,1,1]},"memory":{"shape":[128,5,1,1,1]},"proj_key_seg_in":{"shape":[128,39,1,1,1]},"state_in_k":{"shape":[32,1,1,20,2]},"tgt":{"shape":[5,1,1,1,1]},"state_in_v":{"shape":[32,1,1,20,2]},"pos_enc":{"shape":[128,1,1,1,1]}},"outputs":{"attn_seg":{"shape":[1,5,1,4,1]},"state_out_v":{"shape":[32,2,1,20,2]},"output":{"shape":[292,5,1,1,1]},"state_out_k":{"shape":[32,2,1,20,2]},"extras_tmp":{"shape":[2,1,1,1,1]},"proj_key_seg_in_tmp":{"shape":[128,39,1,1,1]},"attn":{"shape":[1,1,1,5,2]},"proj_key_seg":{"shape":[128,1,1,20,1]}}} : string_id=0x70ac000000015257 : program=_ANEProgramForEvaluation: { programHandle=10000241581886 : intermediateBufferHandle=10000242143532 : queueDepth=32 } : state=3 : programHandle=10000241581886 : intermediateBufferHandle=10000242143532 : queueDepth=32 : attr=... : perfStatsMask=0}  i dont see any obvious error messages in com.apple.ane, com.apple.coreml or com.apple.espresso. where/what should i look for to understand what is going on? and in particular why the ANE model was unloaded? Thank you
Replies
2
Boosts
0
Views
2.1k
Activity
Feb ’23
PyTorch Training on iOS Devices
Is there any way to train PyTorch models directly on-device on an iPhone via the GPU? PyTorch Mobile docs seems to be completely focused on inference only, as do the iOS app examples (https://github.com/pytorch/ios-demo-app). I did find this article about using MPS backend on Macs (https://developer.apple.com/metal/pytorch/), but not sure if this is at all viable for iOS devices. There's also this prototype article about using iOS GPU for PyTorch mobile (https://pytorch.org/tutorials/prototype/ios_gpu_workflow.html), but it too seems to be focused on inference only. We are attempting to train a large language model on the iPhone 14 and we would like to a) discard intermediate activations and recompute them, and b) manage memory directly to write some intermediate activations to the filesystem and later read them back. We suspect that converting a PyTorch model to CoreML format and using CoreML for training would prevent us from making these low-level modifications, but PyTorch might have the APIs necessary for this. If there's any examples/pointers that anyone can link to that would be great.
Replies
1
Boosts
0
Views
3.5k
Activity
Feb ’23
Not able to run scripts in PyCharm on Macbook Air M2
Hi, I have been trying to run python scripts on PyCharm but haven't been able to. I have tried different versions of python and a lot of package managers. I haven't been able to run the scripts and haven't been able to pip install tensorflow either.
Replies
0
Boosts
0
Views
1.3k
Activity
Jan ’23
Cannot use XLA accelerator Tensorflow in M1 silicon
I'm trying to use XLA in TensorFlow using jit_compile=True, currently. However, the error looks like it cannot. First of all, I tried simple code as below, import tensorflow as tf @tf.function(jit_compile=True) def operation(a, b): return a * b And, I got an error as below, (base) ***@MacBook-Pro folder % /Users/***/miniforge3/envs/testtf/bin/python /Users/***/workplace/research/folder/subfolder/test/test_jit_compile.py Metal device set to: Apple M1 Pro systemMemory: 32.00 GB maxCacheSize: 10.67 GB 2023-01-11 12:45:18.794439: I tensorflow/core/common_runtime/pluggable_device/pluggable_device_factory.cc:306] Could not identify NUMA node of platform GPU ID 0, defaulting to 0. Your kernel may not have been built with NUMA support. 2023-01-11 12:45:18.794689: I tensorflow/core/common_runtime/pluggable_device/pluggable_device_factory.cc:272] Created TensorFlow device (/job:localhost/replica:0/task:0/device:GPU:0 with 0 MB memory) -> physical PluggableDevice (device: 0, name: METAL, pci bus id: <undefined>) 2023-01-11 12:45:18.808796: W tensorflow/core/framework/op_kernel.cc:1830] OP_REQUIRES failed at xla_ops.cc:418 : NOT_FOUND: could not find registered platform with id: 0x10c7ba7e0 Traceback (most recent call last): File "/Users/***/workplace/research/folder/subfolder/test/test_jit_compile.py", line 25, in <module> print(operation(3, 4)) File "/Users/***/miniforge3/envs/testtf/lib/python3.8/site-packages/tensorflow/python/util/traceback_utils.py", line 153, in error_handler raise e.with_traceback(filtered_tb) from None File "/Users/***/miniforge3/envs/testtf/lib/python3.8/site-packages/tensorflow/python/eager/execute.py", line 52, in quick_execute tensors = pywrap_tfe.TFE_Py_Execute(ctx._handle, device_name, op_name, tensorflow.python.framework.errors_impl.NotFoundError: could not find registered platform with id: 0x10c7ba7e0 [Op:__inference_operation_5] This seems like XLA did not register. Would you guide how to use jit_compile=True in this environment? I attached my environment as below also. Package Version ----------------------- --------- absl-py 1.3.0 astunparse 1.6.3 cachetools 5.2.1 certifi 2022.12.7 charset-normalizer 2.1.1 flatbuffers 23.1.4 gast 0.4.0 google-auth 2.16.0 google-auth-oauthlib 0.4.6 google-pasta 0.2.0 grpcio 1.42.0 h5py 3.6.0 idna 3.4 importlib-metadata 6.0.0 keras 2.11.0 libclang 15.0.6.1 Markdown 3.4.1 MarkupSafe 2.1.1 numpy 1.22.3 oauthlib 3.2.2 opt-einsum 3.3.0 packaging 23.0 pip 22.3.1 protobuf 3.19.6 pyasn1 0.4.8 pyasn1-modules 0.2.8 requests 2.28.1 requests-oauthlib 1.3.1 rsa 4.9 setuptools 65.6.3 six 1.16.0 tensorboard 2.11.0 tensorboard-data-server 0.6.1 tensorboard-plugin-wit 1.8.1 tensorflow-estimator 2.11.0 tensorflow-macos 2.11.0 tensorflow-metal 0.7.0 termcolor 2.2.0 typing_extensions 4.4.0 urllib3 1.26.13 Werkzeug 2.2.2 wheel 0.37.1 wrapt 1.14.1 zipp 3.11.0 Thanks.
Replies
3
Boosts
0
Views
2.8k
Activity
Jan ’23
How can I construct an MLModelAsset using data from an in-memory representation?
I’m developing a macOS app that uses a proprietary Core ML model, which I need to encrypt. Since Core ML doesn’t support model encryption on macOS, I plan to encrypt the model myself using a symmetric key and decrypt it at runtime. To minimize the possibility of the model being compromised, I’d like to ensure that the decrypted model is only accessible in-memory, not on-disk. So my app will load the encrypted data, decrypt it with CryptoKit, construct an MLModelAsset with the decrypted data, and load that with MLModel.load(MLModelAsset...). The part I’m stuck on is constructing the MLModelAsset. It only has one initializer method: init(specification: Data), where specification is described as “[t]he contents of a .mlmodel as a data blob.” My model is in the .mlpackage format, which is a macOS package (i.e. a directory, not a blob). Attempting to initialize MLModelAsset with the (unencrypted) .mlmodel file stored inside the .mlpackage (under “Data/com.apple.CoreML/model.mlmodel”) throws an error: testLoadingPlainTextModel(): failed: caught error: "Error Domain=com.apple.CoreML Code=0 "compiler error:  Encountered an error while compiling a neural network model: in operation op_7_to_fp16: Cannot interpret @model_path when ModelPath is unset" UserInfo={NSLocalizedDescription=compiler error:  Encountered an error while compiling a neural network model: in operation op_7_to_fp16: Cannot interpret @model_path when ModelPath is unset}" Since .mlpackage stores the model architecture and the weights in separate files, this isn’t unexpected. But I have no idea how to load the .mlpackage (or the corresponding .mlmodelc) as a blob, since they’re both directories and Data(contentsOf:) throws an error if you try to load them. (Note: I’m testing all this without any encryption for the time being—neither the .mlpackage or .mlmodelc is encrypted in my test project.) What am I doing wrong? Is there any way to load an .mlpackage or .mlmodelc package as a blob, for instantiating MLModelAsset? Or is there a different/better way to encrypt Core ML models on macOS? Thanks!
Replies
2
Boosts
0
Views
1.5k
Activity
Jan ’23
Core ML: Strong increase in load time with quantisation from 16 to 8 bits
Hi, I have a BERT-large model that has been quantised to 16 bits. According to the performance report, the model takes about 500 ms to load: If I quantise the model further to 8 bits, the loading time increases drastically to almost 2500 ms. That is a fivefold increase: Does anyone have an explanation for this? I would rather have expected a reduction in the loading time, since the model is only half as large due to the further quantisation. I have carried out the measurements several times and always come to the same result. My only idea is that it might be due to the compute precision, which is limited to 16 bits in the CPU, GPU and NPU.
Replies
0
Boosts
0
Views
1.2k
Activity
Jan ’23
FullyConnectedNetworkRegressor activation functions
Hi, I am using FullyConnectedNetworkRegressor to build an ML pipeline. The FullyConnectedNetworkConfiguration allows one to specify hiddenUnitCounts for the hidden layers, but I don't see any way to specify or get the activation function for the hidden layers. Is there a way to specify the activation function for the hidden layers? If not, does anyone know what activation function is used for the hidden layers or how they are determined? Thanks, Tom
Replies
2
Boosts
0
Views
1k
Activity
Jan ’23