簡體   English   中英

Windows 上的 TensorFlow tensorflow_transform.beam 問題

[英]Issue with TensorFlow tensorflow_transform.beam on Windows

在我的本地 Win10 機器上運行以下代碼並遇到錯誤。

導入以下包:

import tensorflow as tf
import tensorflow_transform as tft
import tensorflow_transform.beam as tft_beam

from tensorflow_transform.tf_metadata import dataset_metadata
from tensorflow_transform.tf_metadata import schema_utils

import pprint
import tempfile

python:3.7.11; windows:10; 張量流變換:1.5.0

# Ignore the warnings
tf.get_logger().setLevel('ERROR')

# a temporary directory is needed when analyzing the data
with tft_beam.Context(temp_dir=tempfile.mkdtemp()):
    
    # define the pipeline using Apache Beam syntax
    transformed_dataset, transform_fn = (
        
        # analyze and transform the dataset using the preprocessing function
        (raw_data, raw_data_metadata) | tft_beam.AnalyzeAndTransformDataset(
            preprocessing_fn)
    )

# unpack the transformed dataset
transformed_data, transformed_metadata = transformed_dataset

# print the results
print('\nRaw data:\n{}\n'.format(pprint.pformat(raw_data)))
print('Transformed data:\n{}'.format(pprint.pformat(transformed_data)))

錯誤快照:

usage: ipykernel_launcher.py [-h] [--dataflow_endpoint DATAFLOW_ENDPOINT]
                             [--project PROJECT] [--job_name JOB_NAME]
                             [--staging_location STAGING_LOCATION]
                             [--temp_location TEMP_LOCATION] [--region REGION]
                             [--service_account_email SERVICE_ACCOUNT_EMAIL]
                             [--no_auth]
                             [--template_location TEMPLATE_LOCATION]
                             [--label LABELS] [--update]
                             [--transform_name_mapping TRANSFORM_NAME_MAPPING]
                             [--enable_streaming_engine]
                             [--dataflow_kms_key DATAFLOW_KMS_KEY]
                             [--create_from_snapshot CREATE_FROM_SNAPSHOT]
                             [--flexrs_goal {COST_OPTIMIZED,SPEED_OPTIMIZED}]
                             [--dataflow_service_option DATAFLOW_SERVICE_OPTIONS]
                             [--enable_hot_key_logging]
ipykernel_launcher.py: error: argument --flexrs_goal: invalid choice: 'C:\\Users\\abc\\AppData\\Local\\Temp\\tmp-17163boS9n25ijAn.json' (choose from 'COST_OPTIMIZED', 'SPEED_OPTIMIZED')
ERROR:root:Internal Python error in the inspect module.
Below is the traceback from this internal error.

有人能幫忙嗎?

此問題可能特定於 VS 代碼。 我在 macOS 上遇到了同樣的問題。 出於某種原因,ipykernel 似乎無法與 tft_beam 很好地配合使用。

這是一些對我有用的解決方法。

  1. 從終端運行 Jupyter 筆記本並使用遠程選項將 VS 代碼連接到它

  2. 使用 nbconvert 將筆記本轉換為 python 文件並運行它。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM