mirror of
https://github.com/tinygrad/tinygrad.git
synced 2026-01-08 22:48:25 -05:00
minor optimizations & cleaning (#257)
* use isinstance, some optimizations & whitespace removal
* revert whitespace changes
* revert more whitespace
* some more cleanup
* revert fstring (not a fan of the {{}})
* fix typo
* fix typo
This commit is contained in:
@@ -37,4 +37,4 @@ if __name__ == "__main__":
|
||||
for i in range(10):
|
||||
im = Image.fromarray(X_train[7353+i])
|
||||
im_aug = [Image.fromarray(x) for x in augment_img(np.array([X_train[7353+i]]*100))]
|
||||
im.save("aug"+str(i)+".gif", save_all=True, append_images=im_aug, duration=100, loop=0)
|
||||
im.save(f"aug{i}.gif", save_all=True, append_images=im_aug, duration=100, loop=0)
|
||||
|
||||
@@ -51,10 +51,10 @@ class KinneDir:
|
||||
"""
|
||||
parameter loads or saves a parameter, given as a tensor.
|
||||
"""
|
||||
path = self.base + str(self.next_part_index) + ".bin"
|
||||
path = f"{self.base}{self.next_part_index}.bin"
|
||||
if self.save:
|
||||
t.data.astype("<f4", "C").tofile(path)
|
||||
self.metadata.write(str(self.next_part_index) + ": " + str(t.shape) + "\n")
|
||||
self.metadata.write(f"{self.next_part_index}: {t.shape}\n")
|
||||
else:
|
||||
t.assign(Tensor(numpy.fromfile(path, "<f4")).reshape(shape=t.shape))
|
||||
self.next_part_index += 1
|
||||
@@ -73,4 +73,3 @@ class KinneDir:
|
||||
def close(self):
|
||||
if self.save:
|
||||
self.metadata.close()
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ def get_parameters(obj):
|
||||
for x in obj:
|
||||
parameters.extend(get_parameters(x))
|
||||
elif hasattr(obj, '__dict__'):
|
||||
for k,v in obj.__dict__.items():
|
||||
for v in obj.__dict__.values():
|
||||
parameters.extend(get_parameters(v))
|
||||
return parameters
|
||||
|
||||
|
||||
Reference in New Issue
Block a user