Skip to content

Commit e36f9d9

Browse files
committed
[DLRM/TF2] Fix numpy bool API change
1 parent 6f3a71a commit e36f9d9

File tree

4 files changed

+7
-7
lines changed

4 files changed

+7
-7
lines changed

TensorFlow2/Recommendation/DLRM_and_DCNv2/dataloading/feature_spec.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ def _check_source_spec_section_model_specific(self):
163163
assert len(contained_features) == 1
164164

165165
# check label dtype
166-
assert np.dtype(self.feature_spec[first_feature][DTYPE_SELECTOR]) == np.bool
166+
assert np.dtype(self.feature_spec[first_feature][DTYPE_SELECTOR]) == bool
167167

168168
else:
169169
assert False, "Feature of unknown type"
@@ -237,7 +237,7 @@ def get_default_feature_spec(number_of_numerical_features, categorical_feature_c
237237
zip(categorical_feature_names, cat_feature_types, categorical_feature_cardinalities)}
238238
for f_name in numerical_feature_names:
239239
feature_dict[f_name] = {DTYPE_SELECTOR: str(np.dtype(np.float16))}
240-
feature_dict[label_feature_name] = {DTYPE_SELECTOR: str(np.dtype(np.bool))}
240+
feature_dict[label_feature_name] = {DTYPE_SELECTOR: str(np.dtype(bool))}
241241

242242
channel_spec = {CATEGORICAL_CHANNEL: categorical_feature_names,
243243
NUMERICAL_CHANNEL: numerical_feature_names,
@@ -297,4 +297,4 @@ def get_categorical_feature_type(size: int):
297297
if size < np.iinfo(numpy_type).max:
298298
return numpy_type
299299

300-
raise RuntimeError(f"Categorical feature of size {size} is too big for defined types")
300+
raise RuntimeError(f"Categorical feature of size {size} is too big for defined types")

TensorFlow2/Recommendation/DLRM_and_DCNv2/dataloading/raw_binary_dataset.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ def _create_readers(self, feature_spec, local_categorical_feature_names, numeric
137137
elif first_feature in set_of_label_features:
138138
# Load label
139139
# We verified earlier that there is only one label feature
140-
label_bytes_per_batch = np.dtype(np.bool).itemsize * self._batch_size
140+
label_bytes_per_batch = np.dtype(bool).itemsize * self._batch_size
141141
self._label, batches = create_reader(path_to_open, label_bytes_per_batch)
142142
else:
143143
raise ValueError("Unknown chunk type")
@@ -231,7 +231,7 @@ def generate(src_train, src_test, feature_spec, dst_dir, dst_feature_spec,
231231
raw_data = feature.numpy().astype(ftype).tobytes()
232232
stream.write(raw_data)
233233

234-
label_f.write(label.numpy().astype(np.bool).tobytes())
234+
label_f.write(label.numpy().astype(bool).tobytes())
235235
numerical_f.write(numerical_features.numpy().astype(np.float16).tobytes())
236236

237237
for stream in chain(*categorical_fs, [label_f, numerical_f]):

TensorFlow2/Recommendation/DLRM_and_DCNv2/dataloading/transcode.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ def main():
116116

117117
# Append them to the binary files
118118
numerical_f.write(numerical_df.values.astype(np.float16).tobytes())
119-
label_f.write(label_df.values.astype(np.bool).tobytes())
119+
label_f.write(label_df.values.astype(bool).tobytes())
120120

121121
categorical_arr = categorical_df.values
122122
for cat_idx, cat_feature_type in enumerate(categorical_feature_types):

TensorFlow2/Recommendation/DLRM_and_DCNv2/preproc/split_dataset.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ def split_binary_file(
6969
numerical_f.write(numerical_features.astype(np.float16).tobytes())
7070

7171
label = batch_data[:, 0]
72-
label_f.write(label.astype(np.bool).tobytes())
72+
label_f.write(label.astype(bool).tobytes())
7373

7474
cat_offset = num_numerical_features + 1
7575
for cat_idx, cat_feature_type in enumerate(cat_feature_types):

0 commit comments

Comments
 (0)