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

Added Derive Seed node #1611

Merged
merged 6 commits into from
Mar 1, 2023
Merged

Conversation

RunDevelopment
Copy link
Member

@RunDevelopment RunDevelopment commented Mar 1, 2023

This PR implements the "derive seed" method I described here.

The new Derive Seed node has a (base) seed input and 10 source inputs. The source inputs can be used to connect sources of randomness that will be used to deterministically derive a seed.

image


That being said, I think that we should make seeds their own datatype. While seeds may be simple integers under the hood, I think that we should not make any guarantees about that (and we currently don't). Seeds being numbers for the type system also creates problems because obvious errors aren't caught. Example:
image
Of course, the type system also determines which nodes are suggested in the content node selector:
image

These 2 factors combined make it actually quite hard to use seeds correctly.

Note that if users want a random number, they should use the Random Number node to turn a seed into a number.

Thoughts?

@joeyballentine
Copy link
Member

Yeah i think that makes sense

@RunDevelopment
Copy link
Member Author

Okay, then I'll also implement that as part of this PR.

@RunDevelopment
Copy link
Member Author

Okay, seeds are now their own datatype. This doesn't change a lot for users, but it did require some interesting code changes.

image

Code changes:

  • Fixed the type system not respecting custom adapters. When the user enters a literal value (either string or number), then we have to convert this literal into a type. This might sounds simple, but inputs like the DirectoryInput make this more complex because the directory input wraps strings. To accommodate this, I added input adapters. Instead of the type system blindly saying "it's a number", inputs can have a custom adapter function that take the literal value and returns the real type of that literal. When implementing this, I didn't expect inputs with default adapters to have custom adpaters. This has been fixed.
  • Added SeedInput (which is just a very special number input) and SeedOutput.
  • Added a Seed class to wrap seeds. This class also contains a few methods to convert seeds to different ranges (e.g. uint32).

@joeyballentine joeyballentine merged commit a001d93 into chaiNNer-org:main Mar 1, 2023
@RunDevelopment RunDevelopment deleted the derive-seed branch March 1, 2023 19:29
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