(exp_dir, out_dir)
| 153 | |
| 154 | |
| 155 | def convert_tensors(exp_dir, out_dir): |
| 156 | def convert_tensors(tensors_file_path): |
| 157 | # Exported value is a path to a .npz file, holding tensor values for all |
| 158 | # points in the entire series. |
| 159 | if os.path.dirname(tensors_file_path) != _TENSORS_DIR: |
| 160 | logging.warning( |
| 161 | "Skipping invalid tensor file path %r", tensors_file_path |
| 162 | ) |
| 163 | return None |
| 164 | npz = np.load(os.path.join(exp_dir, tensors_file_path)) |
| 165 | return [tensor_util.make_tensor_proto(npz[key]) for key in npz.files] |
| 166 | |
| 167 | run_to_series = load_run_to_series(os.path.join(exp_dir, _TENSORS_FILE)) |
| 168 | for run, series_list in run_to_series.items(): |
| 169 | w = create_writer_for_run(out_dir, run, "tensors") |
| 170 | for series in series_list: |
| 171 | tag = series["tag"] |
| 172 | summary_metadata = base64.b64decode(series["summary_metadata"]) |
| 173 | tensors = convert_tensors(series["points"]["tensors_file_path"]) |
| 174 | if tensors is None: |
| 175 | continue |
| 176 | if len(tensors) != len(series["points"]["steps"]): |
| 177 | logging.warning( |
| 178 | "Skipping tag %r in run %r with incomplete tensor data", |
| 179 | tag, |
| 180 | run, |
| 181 | ) |
| 182 | points = zip( |
| 183 | series["points"]["steps"], |
| 184 | series["points"]["wall_times"], |
| 185 | tensors, |
| 186 | ) |
| 187 | for step, wall_time, tensor in points: |
| 188 | e = Event(step=step, wall_time=wall_time) |
| 189 | e.summary.value.add(tag=tag, tensor=tensor) |
| 190 | e.summary.value[0].metadata.MergeFromString(summary_metadata) |
| 191 | w.add_event(e) |
| 192 | w.close() |
| 193 | |
| 194 | |
| 195 | def convert_blobs(exp_dir, out_dir): |
no test coverage detected
searching dependent graphs…