尝试 运行 next(iter(train_data_loader)) 时遇到 Broken Pipe 错误。我在本地 jupyter notebook 中 运行ning 代码
Facing Broken Pipe error when trying to run the next(iter(train_data_loader)). I'm running the code in local jupyter notebook
当我尝试 运行 拥抱面孔的情绪分析时,我遇到了 BrokenPipeError。它返回 [Error No] 32 Broken Pipe。 有没有办法重写next(iter(train_data_loader))的代码?
Link 总代码为“https://colab.research.google.com/drive/1wBXKa-gkbSPPk-o7XdwixcGk7gSHRMas?usp=sharing”
密码是
def create_data_loader(df, tokenizer, max_len, batch_size):
ds = GPReviewDataset(
reviews=df.content.to_numpy(),
targets=df.sentiment.to_numpy(),
tokenizer=tokenizer,
max_len=max_len
)
return DataLoader(
ds,
batch_size=batch_size,
num_workers=4
)
接着是下面的代码
BATCH_SIZE = 16
train_data_loader = create_data_loader(df_train, tokenizer, MAX_LEN, BATCH_SIZE)
val_data_loader = create_data_loader(df_val, tokenizer, MAX_LEN, BATCH_SIZE)
test_data_loader = create_data_loader(df_test, tokenizer, MAX_LEN, BATCH_SIZE)
其次是
data = next(iter(train_data_loader))
data.keys()
我遇到此“data = next(iter(train_data_loader))
”代码的错误
错误是BrokenPipeError: [Errno 32] Broken pipe
此问题的原因之一可能是 OS。使用 Windows 时,不应定义 num_worker
,因为 PyTorch 数据加载器不支持 Windows 上的多处理。默认情况下 num_workers
是 0
并且适用于 Windows.
DataLoader(
ds,
batch_size=batch_size,
num_workers=0 # should be zero on Windows
)
当我尝试 运行 拥抱面孔的情绪分析时,我遇到了 BrokenPipeError。它返回 [Error No] 32 Broken Pipe。 有没有办法重写next(iter(train_data_loader))的代码?
Link 总代码为“https://colab.research.google.com/drive/1wBXKa-gkbSPPk-o7XdwixcGk7gSHRMas?usp=sharing”
密码是
def create_data_loader(df, tokenizer, max_len, batch_size):
ds = GPReviewDataset(
reviews=df.content.to_numpy(),
targets=df.sentiment.to_numpy(),
tokenizer=tokenizer,
max_len=max_len
)
return DataLoader(
ds,
batch_size=batch_size,
num_workers=4
)
接着是下面的代码
BATCH_SIZE = 16
train_data_loader = create_data_loader(df_train, tokenizer, MAX_LEN, BATCH_SIZE)
val_data_loader = create_data_loader(df_val, tokenizer, MAX_LEN, BATCH_SIZE)
test_data_loader = create_data_loader(df_test, tokenizer, MAX_LEN, BATCH_SIZE)
其次是
data = next(iter(train_data_loader))
data.keys()
我遇到此“data = next(iter(train_data_loader))
”代码的错误
错误是BrokenPipeError: [Errno 32] Broken pipe
此问题的原因之一可能是 OS。使用 Windows 时,不应定义 num_worker
,因为 PyTorch 数据加载器不支持 Windows 上的多处理。默认情况下 num_workers
是 0
并且适用于 Windows.
DataLoader(
ds,
batch_size=batch_size,
num_workers=0 # should be zero on Windows
)