MCPcopy Index your code
hub / github.com/THUDM/GLM / write

Method write

data_utils/datasets.py:333–354  ·  view source on GitHub ↗

given a generator of metrics for each of the data points X_i, write the metrics, text, and labels to a csv file

(self, writer_gen=None, path=None, skip_header=False)

Source from the content-addressed store, hash-verified

331 return {'text': x, 'length': len(x), 'label': y}
332
333 def write(self, writer_gen=None, path=None, skip_header=False):
334 """
335 given a generator of metrics for each of the data points X_i,
336 write the metrics, text, and labels to a csv file
337 """
338 if path is None:
339 path = self.path + '.results'
340 print('generating csv at ' + path)
341 with open(path, 'w') as csvfile:
342 c = csv.writer(csvfile, delimiter=self.delim)
343 if writer_gen is not None:
344 # if first item of generator is a header of what the metrics mean then write header to csv file
345 if not skip_header:
346 header = (self.label_key,) + tuple(next(writer_gen)) + (self.text_key,)
347 c.writerow(header)
348 for i, row in enumerate(writer_gen):
349 row = (self.Y[i],) + tuple(row) + (self.X[i],)
350 c.writerow(row)
351 else:
352 c.writerow([self.label_key, self.text_key])
353 for row in zip(self.Y, self.X):
354 c.writerow(row)
355
356
357class json_dataset(data.Dataset):

Callers 15

_trainFunction · 0.45
finetuneFunction · 0.45
save_checkpointFunction · 0.45
read_contextFunction · 0.45
generate_samplesFunction · 0.45
change_mp.pyFile · 0.45
mainFunction · 0.45
default_output_funcFunction · 0.45
output_predictionMethod · 0.45
output_predictionMethod · 0.45
output_predictionMethod · 0.45
output_predictionMethod · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected