You can now leverage Apple’s tensorflow-metal PluggableDevice in TensorFlow v2.5 for accelerated training on Mac GPUs directly with Metal. Learn more here.
def load_attributes_from_hdf5_group(group, name): """Loads attributes of the specified name from the HDF5 group.
This method deals with an inherent problem of HDF5 file which is not able to store data larger than HDF5_OBJECT_HEADER_LIMIT bytes.
Arguments: group: A pointer to a HDF5 group. name: A name of the attributes to load.
Returns: data: Attributes data. """ if name in group.attrs: - data = [n.decode('utf8') for n in group.attrs[name]] + data = [ + n.decode('utf8') if hasattr(n, 'decode') else n + for n in group.attrs[name] + ] else: data = [] chunk_id = 0 while '%s%d' % (name, chunk_id) in group.attrs: - data.extend( - [n.decode('utf8') for n in group.attrs['%s%d' % (name, chunk_id)]]) + data.extend([ + n.decode('utf8') if hasattr(n, 'decode') else n + for n in group.attrs['%s%d' % (name, chunk_id)] + ]) chunk_id += 1 return data