Posts

Post not yet marked as solved
0 Replies
396 Views
I was trying to test out ResNet for my new M1 MacBook Pro - with Apple's new tensorflow version 2.4.0-rc0 and Numpy version 1.21.1 - with the following code: import tensorflow as tf from tensorflow import keras import numpy as np from sklearn.datasets import load_sample_image model = keras.applications.resnet50.ResNet50(weights="imagenet") china = load_sample_image("china.jpg") / 255 flower = load_sample_image("flower.jpg") / 255 images = np.array([china, flower]) images_resized = tf.image.resize(images, [224, 224]) inputs = keras.applications.resnet50.preprocess_input(images_resized * 255) y_proba = model.predict(inputs) Which gives the following error: *** Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[__NSArrayM objectAtIndexedSubscript:]: index 0 beyond bounds for empty array' *** First throw call stack: ( 0 CoreFoundation 0x000000018cea8c78 __exceptionPreprocess + 240 1 libobjc.A.dylib 0x000000018cbd10a8 objc_exception_throw + 60 2 CoreFoundation 0x000000018cf73b68 -[__NSCFString characterAtIndex:].cold.1 + 0 3 CoreFoundation 0x000000018ce16ac8 -[__NSArrayM objectAtIndexedSubscript:] + 188 4 MLCompute 0x00000001962f06a0 -[MLCDeviceCPU(MLCLayerOperations) updateTensorsForFusedPaddingAndConvolutionLayer:layerNext:] + 276 5 MLCompute 0x00000001962f0e5c -[MLCDeviceCPU(MLCLayerOperations) fuseLayersForGraph:stopGradientTensorList:startAtLayerIndex:forInference:] + 1264 6 MLCompute 0x0000000196352f68 -[MLCInferenceGraph compileWithOptions:device:inputTensors:inputTensorsData:] + 1868 7 _pywrap_tensorflow_internal.so 0x0000000144e16848 _ZN10tensorflow9mlcompute7convert26MLCGraphConversionPassImpl15ConvertSubgraphEPNS_15OpKernelContextEPNS1_11TFGraphInfoEPKNS_5GraphERKNSt3__16vectorINSA_12basic_stringIcNSA_11char_traitsIcEENSA_9allocatorIcEEEENSF_ISH_EEEERKNSB_IiNSF_IiEEEEPNS1_24MLCSubgraphConvertResultE + 3516 8 _pywrap_tensorflow_internal.so 0x0000000144df8498 _ZN10tensorflow9mlcompute7kernels13MLCSubgraphOp20ProcessMLCSubgraphOpEPNS_15OpKernelContextEPPNS1_10MLCContextEPPNS1_15TFContextStatusE + 416 9 _pywrap_tensorflow_internal.so 0x0000000144dfb1c0 _ZN10tensorflow9mlcompute7kernels13MLCSubgraphOp7ComputeEPNS_15OpKernelContextE + 804 10 libtensorflow_framework.2.dylib 0x00000001587a7598 _ZN10tensorflow12_GLOBAL__N_113ExecutorStateINS_21SimplePropagatorStateEE7ProcessENS2_10TaggedNodeEx + 2772 11 libtensorflow_framework.2.dylib 0x000000015881a50c _ZN5Eigen15ThreadPoolTemplIN10tensorflow6thread16EigenEnvironmentEE10WorkerLoopEi + 552 12 libtensorflow_framework.2.dylib 0x000000015881a1e4 _ZZN10tensorflow6thread16EigenEnvironment12CreateThreadENSt3__18functionIFvvEEEENKUlvE_clEv + 80 13 libtensorflow_framework.2.dylib 0x000000015880bacc _ZN10tensorflow12_GLOBAL__N_17PThread8ThreadFnEPv + 104 14 libsystem_pthread.dylib 0x000000018cd2b878 _pthread_start + 320 15 libsystem_pthread.dylib 0x000000018cd265e0 thread_start + 8 ) libc++abi: terminating with uncaught exception of type NSException Please let me know whats up - it seems that none of the other questions with the same NSRangeException are concerning Keras. The same issue on GitHub was closed. I am new to this so any help would be greatly appreciated!
Posted
by EW0824.
Last updated
.