Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Misc improvements #1333

Open
wants to merge 4 commits into
base: pytorch
Choose a base branch
from
Open

Misc improvements #1333

wants to merge 4 commits into from

Conversation

le-horizon
Copy link
Contributor

adding various asserts, debug messages, and small improvements

Comment on lines 546 to 547
if output_activation is None:
output_activation = alf.math.identity
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems unnecessary. Can provide alf.math.identity as argument.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. Removed.

Comment on lines 43 to 56
# ox = (x * torch.arange(
# batch_size, dtype=torch.float32, requires_grad=True,
# device="cpu").unsqueeze(1) * torch.arange(
# dim, dtype=torch.float32, requires_grad=True,
# device="cpu").unsqueeze(0))
if batch_size > 1 and x.ndim > 0 and batch_size == x.shape[0]:
a = x
else:
a = x * torch.ones(batch_size, dtype=torch.float32, device="cpu")
if batch_size > 1 and t.ndim > 0 and batch_size == t.shape[0]:
pass
else:
t = t * torch.ones(batch_size, dtype=torch.int32, device="cpu")
ox = a.unsqueeze(1).clone().requires_grad_(True)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is the purpose of this change?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is needed because we allow x and t inputs to be scalars, which will be expanded to be consistent with the batch_size. Made code easier to read, and commented.

# Most of the times, for command line flags, this warning is a false alarm.
# This can be useful in other failures, e.g. when the Config has already been used,
# before configuring its value.
logging.warning("pre_config potential error: %s", e)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This warning is hard to understand. It's better to identify the case of the Config has already been used. Perhaps throw a different type of Exception when config has been used in config1()?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. Logging error in config1.

Copy link
Contributor Author

@le-horizon le-horizon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the comments. Done all, PTAL.

Le

# Most of the times, for command line flags, this warning is a false alarm.
# This can be useful in other failures, e.g. when the Config has already been used,
# before configuring its value.
logging.warning("pre_config potential error: %s", e)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. Logging error in config1.

Comment on lines 546 to 547
if output_activation is None:
output_activation = alf.math.identity
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. Removed.

Comment on lines 43 to 56
# ox = (x * torch.arange(
# batch_size, dtype=torch.float32, requires_grad=True,
# device="cpu").unsqueeze(1) * torch.arange(
# dim, dtype=torch.float32, requires_grad=True,
# device="cpu").unsqueeze(0))
if batch_size > 1 and x.ndim > 0 and batch_size == x.shape[0]:
a = x
else:
a = x * torch.ones(batch_size, dtype=torch.float32, device="cpu")
if batch_size > 1 and t.ndim > 0 and batch_size == t.shape[0]:
pass
else:
t = t * torch.ones(batch_size, dtype=torch.int32, device="cpu")
ox = a.unsqueeze(1).clone().requires_grad_(True)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is needed because we allow x and t inputs to be scalars, which will be expanded to be consistent with the batch_size. Made code easier to read, and commented.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants