bert4keras icon indicating copy to clipboard operation
bert4keras copied to clipboard

fortest方法

Open xswings opened this issue 4 years ago • 1 comments

https://github.com/bojone/bert4keras/blob/4dcda150b54ded71420c44d25ff282ed30f3ea42/bert4keras/snippets.py#L433 fortest是不是应该以参数的形式从to_dataset中传递进来(和forfit对应)?貌似目前没有用到呢?目前似乎只能逐条测试否则都会打乱? ` class data_generator_fortest(DataGenerator): """数据生成器 """

def __iter__(self, random=False):
    for is_end, (text, label) in self.sample(random):
        token_ids, segment_ids = tokenizer.encode(text, maxlen=maxlen)
        yield [token_ids, segment_ids], [[label]]  # 返回一条样本

def forfit(self, random=False):
    while True:
        for d in self.__iter__(random):
            yield d

` 我是这样实现的禁止random,,,不是很优雅。

xswings avatar Feb 15 '22 13:02 xswings

不是本来就默认random=False了么?没看懂你想表达什么

bojone avatar Feb 15 '22 13:02 bojone