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 24
24
from __future__ import division
25
25
from __future__ import print_function
26
26
27
- from typing import Optional , Iterator
27
+ from typing import Iterator , Optional
28
28
29
29
import tensorflow as tf
30
30
@@ -56,9 +56,22 @@ def open(self, path: str):
56
56
if magic != b"BS" :
57
57
raise ValueError (f"Invalid blob sequence file { path } " )
58
58
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
+ )
62
75
del reserved
63
76
64
77
def close (self ):
You can’t perform that action at this time.
0 commit comments