关于“[DEPRECATED] Training and Deploying a TensorFlow Model in Vertex AI”的评价
评论
Gavriel D. · 评论about 1 year之前
Gavriel D. · 评论about 1 year之前
Callum G. · 评论about 1 year之前
Enzo P. · 评论about 1 year之前
Daniel C. · 评论about 1 year之前
Qi Rong L. · 评论about 1 year之前
vinuharini S. · 评论about 1 year之前
Yasmine E. · 评论about 1 year之前
Souriya K. · 评论about 1 year之前
Renato M. · 评论about 1 year之前
better
arya k. · 评论about 1 year之前
FRANCESCO G. · 评论about 1 year之前
Miguel D. · 评论about 1 year之前
not able to activate cloudshell
Magarajothika M. · 评论about 1 year之前
Jonathan E. · 评论about 1 year之前
Mohan G. · 评论about 1 year之前
Kunal A. · 评论about 1 year之前
Panos K. · 评论about 1 year之前
Oliver W. · 评论about 1 year之前
Mohammad A. · 评论about 1 year之前
ok
Dharmaraj P. · 评论about 1 year之前
I am not sure if the lab is working. I receive a lot of errors: --------------------------------------------------------------------------- NotFoundError Traceback (most recent call last) Cell In[5], line 5 3 import numpy as np 4 import pandas as pd ----> 5 import tensorflow as tf 6 import matplotlib.pyplot as plt 8 from google.cloud import aiplatform File /opt/conda/lib/python3.9/site-packages/tensorflow/__init__.py:438 436 _main_dir = _os.path.join(_s, 'tensorflow/core/kernels') 437 if _os.path.exists(_main_dir): --> 438 _ll.load_library(_main_dir) 440 # Load third party dynamic kernels. 441 _plugin_dir = _os.path.join(_s, 'tensorflow-plugins') File /opt/conda/lib/python3.9/site-packages/tensorflow/python/framework/load_library.py:154, in load_library(library_location) 151 kernel_libraries = [library_location] 153 for lib in kernel_libraries: --> 154 py_tf.TF_LoadLibrary(lib) 156 else: 157 raise OSError( 158 errno.ENOENT, 159 'The file or folder to load kernel libraries from does not exist.', 160 library_location) NotFoundError: /home/jupyter/.local/lib/python3.9/site-packages/tensorflow/core/kernels/libtfkernel_sobol_op.so: undefined symbol: _ZNK10tensorflow8OpKernel11TraceStringB5cxx11ERKNS_15OpKernelContextEb --------------------------------------------------------------------------- NameError Traceback (most recent call last) Cell In[6], line 1 ----> 1 aiplatform.init(project=PROJECT_ID, location=REGION, staging_bucket=f"gs://{GCS_BUCKET}") NameError: name 'aiplatform' is not defined /opt/conda/lib/python3.9/site-packages/pandas/plotting/_matplotlib/core.py:1114: UserWarning: No data for colormapping provided via 'c'. Parameters 'cmap' will be ignored scatter = ax.scatter( --------------------------------------------------------------------------- NameError Traceback (most recent call last) Cell In[38], line 1 ----> 1 trainds = df_dataset(clv_train).prefetch(1).batch(BATCH_SIZE).repeat() 2 devds = df_dataset(clv_dev).prefetch(1).batch(BATCH_SIZE) 3 testds = df_dataset(clv_test).prefetch(1).batch(BATCH_SIZE) Cell In[37], line 3, in df_dataset(df) 1 def df_dataset(df): 2 """Transform Pandas Dataframe to TensorFlow Dataset.""" ----> 3 return tf.data.Dataset.from_tensor_slices((df[NUMERIC_FEATURES].to_dict('list'), df[LABEL].values)) NameError: name 'tf' is not defined -------------------------------------------------------------------------- NameError Traceback (most recent call last) Cell In[39], line 37 31 model.compile(loss=tf.keras.losses.MAE, 32 optimizer=optimizer, 33 metrics=[['mae', 'mse', rmse]]) 35 return model ---> 37 model = build_model() Cell In[39], line 9, in build_model() 7 """Build and compile a TensorFlow Keras Regressor.""" 8 # Define input feature tensors and input layers. ----> 9 feature_columns = [ 10 tf.feature_column.numeric_column(key=feature) 11 for feature in NUMERIC_FEATURES 12 ] 14 input_layers = { 15 feature.key: tf.keras.layers.Input(name=feature.key, shape=(), dtype=tf.float32) 16 for feature in feature_columns 17 } 19 # Keras Functional API: https://keras.io/guides/functional_api Cell In[39], line 10, in <listcomp>(.0) 7 """Build and compile a TensorFlow Keras Regressor.""" 8 # Define input feature tensors and input layers. 9 feature_columns = [ ---> 10 tf.feature_column.numeric_column(key=feature) 11 for feature in NUMERIC_FEATURES 12 ] 14 input_layers = { 15 feature.key: tf.keras.layers.Input(name=feature.key, shape=(), dtype=tf.float32) 16 for feature in feature_columns 17 } 19 # Keras Functional API: https://keras.io/guides/functional_api NameError: name 'tf' is not defined --------------------------------------------------------------------------- NameError Traceback (most recent call last) Cell In[40], line 1 ----> 1 tf.keras.utils.plot_model(model, show_shapes=False, rankdir="LR") NameError: name 'tf' is not defined -------------------------------------------------------------------------- NameError Traceback (most recent call last) Cell In[41], line 1 ----> 1 tensorboard_callback = tf.keras.callbacks.TensorBoard( 2 log_dir='./local-training/tensorboard', 3 histogram_freq=1) 5 earlystopping_callback = tf.keras.callbacks.EarlyStopping(patience=1) 7 checkpoint_callback = tf.keras.callbacks.ModelCheckpoint( 8 filepath='./local-training/checkpoints', 9 save_weights_only=True, 10 monitor='val_loss', 11 mode='min') NameError: name 'tf' is not defined --------------------------------------------------------------------------- NameError Traceback (most recent call last) Cell In[42], line 1 ----> 1 history = model.fit(trainds, 2 validation_data=devds, 3 steps_per_epoch=STEPS_PER_EPOCH, 4 epochs=N_CHECKPOINTS, 5 callbacks=[[tensorboard_callback, 6 earlystopping_callback, 7 checkpoint_callback]]) NameError: name 'model' is not defined --------------------------------------------------------------------------- NameError Traceback (most recent call last) Cell In[43], line 3 1 LOSS_COLS = ["loss", "val_loss"] ----> 3 pd.DataFrame(history.history)[LOSS_COLS].plot(); NameError: name 'history' is not defined --------------------------------------------------------------------------- NameError Traceback (most recent call last) Cell In[44], line 1 ----> 1 train_pred = model.predict(df_dataset(clv_train).prefetch(1).batch(BATCH_SIZE)) 2 dev_pred = model.predict(devds) 3 test_pred = model.predict(testds) NameError: name 'model' is not defined --------------------------------------------------------------------------- NameError Traceback (most recent call last) Cell In[45], line 1 ----> 1 train_results = pd.DataFrame({'actual': clv_train['target_monetary_value_3M'].to_numpy(), 'predicted': np.squeeze(train_pred)}, columns=['actual', 'predicted']) 2 dev_results = pd.DataFrame({'actual': clv_dev['target_monetary_value_3M'].to_numpy(), 'predicted': np.squeeze(dev_pred)}, columns=['actual', 'predicted']) 3 test_results = pd.DataFrame({'actual': clv_test['target_monetary_value_3M'].to_numpy(), 'predicted': np.squeeze(test_pred)}, columns=['actual', 'predicted']) NameError: name 'train_pred' is not defined --------------------------------------------------------------------------- NameError Traceback (most recent call last) Cell In[46], line 2 1 # Model prediction calibration plots. ----> 2 fig, (train_ax, dev_ax, test_ax) = plt.subplots(1, 3, figsize=(15,15)) 4 train_results.plot(kind='scatter', 5 x='predicted', 6 y='actual', 7 title='Train: act vs. pred customer 3M monetary value', 8 grid=True, 9 ax=train_ax) 11 train_lims = [ 12 np.min([train_ax.get_xlim(), train_ax.get_ylim()]), # min of both axes 13 np.max([train_ax.get_xlim(), train_ax.get_ylim()]), # max of both axes 14 ] NameError: name 'plt' is not defined --------------------------------------------------------------------------- NameError Traceback (most recent call last) Cell In[47], line 1 ----> 1 tabular_dataset = aiplatform.TabularDataset.create(display_name="online-retail-clv", bq_source=f"{BQ_URI}") NameError: name 'aiplatform' is not defined --------------------------------------------------------------------------- NameError Traceback (most recent call last) Cell In[62], line 1 ----> 1 job = aiplatform.CustomContainerTrainingJob( 2 display_name="online-retail-clv-3M-dnn-regressor", 3 container_uri=IMAGE_URI, 4 # https://cloud.google.com/vertex-ai/docs/predictions/pre-built-containers 5 # gcr.io/cloud-aiplatform/prediction/tf2-cpu.2-3:latest 6 model_serving_container_image_uri="us-docker.pkg.dev/vertex-ai/prediction/tf2-cpu.2-3:latest", 7 ) 9 model = job.run( 10 dataset=tabular_dataset, 11 model_display_name=MODEL_NAME, (...) 26 service_account=f"vertex-custom-training-sa@{PROJECT_ID}.iam.gserviceaccount.com" 27 ) NameError: name 'aiplatform' is not defined --------------------------------------------------------------------------- NameError Traceback (most recent call last) Cell In[64], line 1 ----> 1 loaded = tf.keras.models.load_model(DEPLOYED_MODEL_DIR) NameError: name 'tf' is not defined --------------------------------------------------------------------------- NameError Traceback (most recent call last) Cell In[65], line 2 1 serving_input = list( ----> 2 loaded.signatures["serving_default"].structured_input_signature[1].keys())[0] 4 serving_output = list(loaded.signatures["serving_default"].structured_outputs.keys())[0] 6 feature_names = [ 7 "n_purchases", 8 "avg_purchase_size", (...) 11 "days_since_last_purchase" 12 ] NameError: name 'loaded' is not defined --------------------------------------------------------------------------- NameError Traceback (most recent call last) Cell In[66], line 4 1 # Specify sampled Shapley feature attribution method with path_count parameter 2 # controlling the number of feature permutations to consider when approximating the Shapley values. ----> 4 explain_params = aiplatform.explain.ExplanationParameters( 5 {"sampled_shapley_attribution": {"path_count": 10}} 6 ) NameError: name 'aiplatform' is not defined --------------------------------------------------------------------------- NameError Traceback (most recent call last) Cell In[67], line 3 1 # https://cloud.google.com/vertex-ai/docs/reference/rest/v1beta1/ExplanationSpec 2 input_metadata = { ----> 3 "input_tensor_name": serving_input, 4 "encoding": "BAG_OF_FEATURES", 5 "modality": "numeric", 6 "index_feature_mapping": feature_names, 7 } 9 output_metadata = {"output_tensor_name": serving_output} 11 input_metadata = aiplatform.explain.ExplanationMetadata.InputMetadata(input_metadata) NameError: name 'serving_input' is not defined --------------------------------------------------------------------------- NameError Traceback (most recent call last) Cell In[68], line 1 ----> 1 endpoint = model.deploy( 2 traffic_split={"0": 100}, 3 machine_type="e2-standard-2", 4 explanation_parameters=explain_params, 5 explanation_metadata=explain_metadata 6 ) NameError: name 'model' is not defined --------------------------------------------------------------------------- NameError Traceback (most recent call last) Cell In[70], line 1 ----> 1 endpoint.predict([test_instance_dict]) NameError: name 'endpoint' is not defined --------------------------------------------------------------------------- NameError Traceback (most recent call last) Cell In[71], line 1 ----> 1 explanations = endpoint.explain([test_instance_dict]) NameError: name 'endpoint' is not defined --------------------------------------------------------------------------- NameError Traceback (most recent call last) Cell In[72], line 1 ----> 1 pd.DataFrame.from_dict(explanations.explanations[0].attributions[0].feature_attributions, orient='index').plot(kind='barh'); NameError: name 'explanations' is not defined
Wiehan W. · 评论about 1 year之前
James G. · 评论about 1 year之前
Reem A. · 评论about 1 year之前
Ana L. · 评论about 1 year之前
我们无法确保发布的评价来自已购买或已使用产品的消费者。评价未经 Google 核实。