【问题标题】:Issue with TensorFlow tensorflow_transform.beam on WindowsWindows 上的 TensorFlow tensorflow_transform.beam 问题
【发布时间】:2022-01-25 16:57:50
【问题描述】:

在我的本地 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

蟒蛇:3.7.11;窗户: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.

有人可以帮忙吗?

【问题讨论】:

    标签: python tensorflow windows-10 apache-beam


    【解决方案1】:

    此问题可能特定于 VS 代码。我在 macOS 上遇到了同样的问题。 出于某种原因,ipykernel 似乎无法与 tft_beam 很好地配合使用。

    这里有几个对我有用的解决方法。

    1. 从终端运行 Jupyter 笔记本并使用远程选项将 VS 代码连接到它

    2. 使用 nbconvert 将笔记本转换为 python 文件并运行它。

    【讨论】:

      猜你喜欢
      • 2020-04-10
      • 2020-12-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-01-28
      • 1970-01-01
      • 2021-05-29
      • 1970-01-01
      相关资源
      最近更新 更多