You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Was following through TensorFlow Developer Certificate in 2023: Zero to Mastery using M1 Macbook Pro and ran into an error in part 166. Building Model 1 (with a data augmentation layer and 1% of training data). Help needed!
Code:
Setup input shape and base model, freezing the base model layers
history_1_percent = model_1.fit(train_data_1_percent,
epochs=5,
steps_per_epoch=len(train_data_1_percent),
validation_data=test_data,
validation_steps=int(0.25 * len(test_data)),
# Track model training logs
callbacks=[create_tensorboard_callback(dir_name='transfer_learning',
experiment_name='1_percent_data_aug')])
Error:
InvalidArgumentError Traceback (most recent call last)
Input In [166], in <cell line: 30>()
25 model_1.compile(loss='categorical_crossentropy',
26 optimizer=tf.keras.optimizers.Adam(),
27 metrics=['accuracy'])
29 ### Fit the model
---> 30 history_1_percent = model_1.fit(train_data_1_percent,
31 epochs=5,
32 steps_per_epoch=len(train_data_1_percent),
33 validation_data=test_data,
34 validation_steps=len(test_data),
35 # Track model training logs
36 callbacks=[create_tensorboard_callback(dir_name='transfer_learning',
37 experiment_name='1_percent_data_aug')])
File ~/tensorflow-test/env/lib/python3.8/site-packages/keras/utils/traceback_utils.py:67, in filter_traceback..error_handler(*args, **kwargs)
65 except Exception as e: # pylint: disable=broad-except
66 filtered_tb = _process_traceback_frames(e.traceback)
---> 67 raise e.with_traceback(filtered_tb) from None
68 finally:
69 del filtered_tb
File ~/tensorflow-test/env/lib/python3.8/site-packages/tensorflow/python/eager/execute.py:54, in quick_execute(op_name, num_outputs, inputs, attrs, ctx, name)
52 try:
53 ctx.ensure_initialized()
---> 54 tensors = pywrap_tfe.TFE_Py_Execute(ctx._handle, device_name, op_name,
55 inputs, attrs, num_outputs)
56 except core._NotOkStatusException as e:
57 if name is not None:
InvalidArgumentError: Cannot assign a device for operation model_18/data_augmentation/random_rotation_1/stateful_uniform/RngReadAndSkip: Could not satisfy explicit device specification '' because the node {{colocation_node model_18/data_augmentation/random_rotation_1/stateful_uniform/RngReadAndSkip}} was colocated with a group of nodes that required incompatible device '/job:localhost/replica:0/task:0/device:GPU:0'. All available devices [/job:localhost/replica:0/task:0/device:CPU:0, /job:localhost/replica:0/task:0/device:GPU:0].
Colocation Debug Info:
Colocation group had the following types and supported devices:
Root Member(assigned_device_name_index_=2 requested_device_name_='/job:localhost/replica:0/task:0/device:GPU:0' assigned_device_name_='/job:localhost/replica:0/task:0/device:GPU:0' resource_device_name_='/job:localhost/replica:0/task:0/device:GPU:0' supported_device_types_=[CPU] possible_devices_=[]
RngReadAndSkip: CPU
_Arg: GPU CPU
Colocation members, user-requested devices, and framework assigned devices, if any:
model_18_data_augmentation_random_rotation_1_stateful_uniform_rngreadandskip_resource (_Arg) framework assigned device=/job:localhost/replica:0/task:0/device:GPU:0
model_18/data_augmentation/random_rotation_1/stateful_uniform/RngReadAndSkip (RngReadAndSkip)
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
Was following through TensorFlow Developer Certificate in 2023: Zero to Mastery using M1 Macbook Pro and ran into an error in part 166. Building Model 1 (with a data augmentation layer and 1% of training data). Help needed!
Code:
Setup input shape and base model, freezing the base model layers
input_shape = (224, 224, 3)
base_model = tf.keras.applications.EfficientNetB0(include_top=False)
base_model.trainable = False
Create input layer
inputs = layers.Input(shape=input_shape, name='input_layer')
Add in data augmentation Sequential model as a layer
x = data_augmentation(inputs)
Give base_model the inputs (after augmentation) and don't train it
x = base_model(x, training=False)
Pool output features of the base model
x = layers.GlobalAveragePooling2D(name='global_average_pooling_layer')(x)
Put a dense layer on as the output
outputs = layers.Dense(10, activation='softmax', name='output_layer')(x)
Make a model using the inputs and outputs
model_1 = keras.Model(inputs, outputs)
Compile the model
model_1.compile(loss='categorical_crossentropy',
optimizer=tf.keras.optimizers.Adam(),
metrics=['accuracy'])
Fit the model
history_1_percent = model_1.fit(train_data_1_percent,
epochs=5,
steps_per_epoch=len(train_data_1_percent),
validation_data=test_data,
validation_steps=int(0.25 * len(test_data)),
# Track model training logs
callbacks=[create_tensorboard_callback(dir_name='transfer_learning',
experiment_name='1_percent_data_aug')])
Error:
InvalidArgumentError Traceback (most recent call last)
Input In [166], in <cell line: 30>()
25 model_1.compile(loss='categorical_crossentropy',
26 optimizer=tf.keras.optimizers.Adam(),
27 metrics=['accuracy'])
29 ### Fit the model
---> 30 history_1_percent = model_1.fit(train_data_1_percent,
31 epochs=5,
32 steps_per_epoch=len(train_data_1_percent),
33 validation_data=test_data,
34 validation_steps=len(test_data),
35 # Track model training logs
36 callbacks=[create_tensorboard_callback(dir_name='transfer_learning',
37 experiment_name='1_percent_data_aug')])
File ~/tensorflow-test/env/lib/python3.8/site-packages/keras/utils/traceback_utils.py:67, in filter_traceback..error_handler(*args, **kwargs)
65 except Exception as e: # pylint: disable=broad-except
66 filtered_tb = _process_traceback_frames(e.traceback)
---> 67 raise e.with_traceback(filtered_tb) from None
68 finally:
69 del filtered_tb
File ~/tensorflow-test/env/lib/python3.8/site-packages/tensorflow/python/eager/execute.py:54, in quick_execute(op_name, num_outputs, inputs, attrs, ctx, name)
52 try:
53 ctx.ensure_initialized()
---> 54 tensors = pywrap_tfe.TFE_Py_Execute(ctx._handle, device_name, op_name,
55 inputs, attrs, num_outputs)
56 except core._NotOkStatusException as e:
57 if name is not None:
InvalidArgumentError: Cannot assign a device for operation model_18/data_augmentation/random_rotation_1/stateful_uniform/RngReadAndSkip: Could not satisfy explicit device specification '' because the node {{colocation_node model_18/data_augmentation/random_rotation_1/stateful_uniform/RngReadAndSkip}} was colocated with a group of nodes that required incompatible device '/job:localhost/replica:0/task:0/device:GPU:0'. All available devices [/job:localhost/replica:0/task:0/device:CPU:0, /job:localhost/replica:0/task:0/device:GPU:0].
Colocation Debug Info:
Colocation group had the following types and supported devices:
Root Member(assigned_device_name_index_=2 requested_device_name_='/job:localhost/replica:0/task:0/device:GPU:0' assigned_device_name_='/job:localhost/replica:0/task:0/device:GPU:0' resource_device_name_='/job:localhost/replica:0/task:0/device:GPU:0' supported_device_types_=[CPU] possible_devices_=[]
RngReadAndSkip: CPU
_Arg: GPU CPU
Colocation members, user-requested devices, and framework assigned devices, if any:
model_18_data_augmentation_random_rotation_1_stateful_uniform_rngreadandskip_resource (_Arg) framework assigned device=/job:localhost/replica:0/task:0/device:GPU:0
model_18/data_augmentation/random_rotation_1/stateful_uniform/RngReadAndSkip (RngReadAndSkip)
Beta Was this translation helpful? Give feedback.
All reactions