Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/338.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python TensorFlow中大型数据库标记化中的递归错误_Python_Tensorflow_Tensorflow Datasets_Tensorflow Estimator - Fatal编程技术网

Python TensorFlow中大型数据库标记化中的递归错误

Python TensorFlow中大型数据库标记化中的递归错误,python,tensorflow,tensorflow-datasets,tensorflow-estimator,Python,Tensorflow,Tensorflow Datasets,Tensorflow Estimator,我有很多txt文件,所以我根据tensorflow教程制作了一个数据集: 我的程序使用smalls数据库,但当我使用包含4956个文本文件的数据库时,我的程序在标记化和升华打印部分完成: RecursionError: maximum recursion depth exceeded while calling a Python object [Finished in 98.1s with exit code 3221225725] 这是我的代码: import tensorflow as

我有很多txt文件,所以我根据tensorflow教程制作了一个数据集:

我的程序使用smalls数据库,但当我使用包含4956个文本文件的数据库时,我的程序在标记化和升华打印部分完成:

RecursionError: maximum recursion depth exceeded while calling a Python object
[Finished in 98.1s with exit code 3221225725]
这是我的代码:

import tensorflow as tf
import tensorflow_datasets as tfds
import os
import numpy as np
print("Num GPUs Available: ", len(tf.config.experimental.list_physical_devices('GPU')))


#---PREPARING THE DATA --------------------------------------------------------------------------------------------

parent_dir=r'C:\Users\ASUS\Desktop\David\Programas\Sequence to tag 1st version\phon_o'
label=0
labeled_data_sets=[]

def labeler(example,index):
    return example,tf.cast(index,tf.int64)

for phase in os.listdir(parent_dir):
    phase_folder=os.path.join(parent_dir,phase)
    if phase == "training":
        for lan in os.listdir(phase_folder):
            lan_folder=os.path.join(phase_folder,lan)
            label=label+1
            for cor in os.listdir(lan_folder):
                cor_path=os.path.join(lan_folder,cor)
                for name in os.listdir(cor_path):
                    names_path=os.path.join(cor_path,name)
                    lines_dataset=tf.data.TextLineDataset(names_path)
                    #here I put the label
                    labeled_dataset=lines_dataset.map(lambda ex:labeler(ex,label))
                    labeled_data_sets.append(labeled_dataset)


BUFFER_SIZE=5000
BATCH_SIZE=64

#multiple datasets into one
all_labeled_data = labeled_data_sets[0]
for labeled_dataset in labeled_data_sets[1:]:
    all_labeled_data=all_labeled_data.concatenate(labeled_dataset)
print(all_labeled_data)


all_labeled_data.shuffle(BUFFER_SIZE, reshuffle_each_iteration=False)



#Tokenizer---------------------

#print()
#print('tokenizer')
tokenizer=tfds.features.text.Tokenizer()
vocabulary_set=set()

for text_tensor, _ in all_labeled_data:
    some_tokens=tokenizer.tokenize(text_tensor.numpy())
    vocabulary_set.update(some_tokens)


vocab_size=len(vocabulary_set)
print(vocab_size)

当我使用我的完整数据库执行时,“vocab size”变量(词汇表数据集的len)没有打印出来,我认为标记化部分有问题,对于小型数据库,这很好,我尝试使用tf.text来实现,但还不能在windows上安装。请帮助我

您可以通过包含以下行来增加代码中的递归深度,然后重试

import sys
sys.setrecursionlimit(1500)
您只需这样做就可以知道递归限制

sys.getrecursionlimit()

您可以通过包含以下行来增加代码中的递归深度,然后重试

import sys
sys.setrecursionlimit(1500)
您只需这样做就可以知道递归限制

sys.getrecursionlimit()