[英]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 很好地配合使用。
这是一些对我有用的解决方法。
从终端运行 Jupyter 笔记本并使用远程选项将 VS 代码连接到它
使用 nbconvert 将笔记本转换为 python 文件并运行它。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.