File tree Expand file tree Collapse file tree 1 file changed +17
-4
lines changed
tensorflow_decision_forests/component/inspector Expand file tree Collapse file tree 1 file changed +17
-4
lines changed Original file line number Diff line number Diff line change 2424from __future__ import division
2525from __future__ import print_function
2626
27- from typing import Optional , Iterator
27+ from typing import Iterator , Optional
2828
2929import tensorflow as tf
3030
@@ -56,9 +56,22 @@ def open(self, path: str):
5656 if magic != b"BS" :
5757 raise ValueError (f"Invalid blob sequence file { path } " )
5858 version = int .from_bytes (self .file_ .read (2 ), byteorder = "little" )
59- if version != 0 :
60- raise ValueError (f"Non supported blob sequence version { path } " )
61- reserved = self .file_ .read (4 )
59+ if version == 0 :
60+ reserved = self .file_ .read (4 )
61+ elif version == 1 :
62+ compression = int .from_bytes (self .file_ .read (1 ), byteorder = "little" )
63+ if compression != 0 :
64+ return ValueError (
65+ "The TF-DF inspector does not support this format of model"
66+ " (blob-sequence-v1 with compression). Use the format"
67+ " blob-sequence-v1 without compression instead."
68+ )
69+ reserved = self .file_ .read (3 )
70+ else :
71+ raise ValueError (
72+ f"Non supported blob sequence version { version } for file { path } . The"
73+ " model was created with a more recent vesion of YDF / TF-DF."
74+ )
6275 del reserved
6376
6477 def close (self ):
You can’t perform that action at this time.
0 commit comments