Tensorflow 一个奇怪的错误------invalidargumeinterror:维度为0的切片索引-1超出范围);

Tensorflow 一个奇怪的错误------invalidargumeinterror:维度为0的切片索引-1超出范围);,tensorflow,tensorflow2.0,Tensorflow,Tensorflow2.0,我的电脑安装了win10、tf-nightly-2.0-preview==2.0.0dev20190926、python3.7和python3.6.8 Tensorflow标准模板: 当我运行tensorflow标准模板时,我在 for image, label in labeled_ds.take(1): print("Image shape: ", image.numpy().shape) print("Label: ", label.numpy()) 错误消息: Inva

我的电脑安装了win10、tf-nightly-2.0-preview==2.0.0dev20190926、python3.7和python3.6.8

Tensorflow标准模板:

当我运行tensorflow标准模板时,我在

for image, label in labeled_ds.take(1):
    print("Image shape: ", image.numpy().shape)
    print("Label: ", label.numpy())
错误消息:

InvalidArgumentError: slice index -1 of dimension 0 out of bounds. [[{{node strided_slice}}]]
Encountered when executing an operation using EagerExecutor. 
此错误将取消所有未来的操作并毒害它们的输出张量

然而,在google colab中,我安装了tf-nightly-2.0-preview==2.0.0dev20190926,python==3.6, 运行代码,但运行良好,没有错误


如果我想在我的计算机上运行这个标准模板代码,我应该如何修改它?

我发现在提供的
get\u label
方法中
tf.strings.split
存在问题。在Colab上,使用单个正斜杠进行拆分是可行的,但在本地Windows计算机上,我需要使用反斜杠进行拆分

因此,如果您的Colab代码如下所示:

def get_标签(文件路径):
parts=tf.strings.split(文件路径“/”)
返回部件[-2]==settings.CLASS\u名称
在本地运行时将其更改为如下所示:

def get_标签(文件路径):
parts=tf.strings.split(文件路径“\\”)
返回部件[-2]==settings.CLASS\u名称