-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #10 from Neuro-Flex/kasinadhsarma/fix-edge-cases
Fix edge cases and deprecated usages in consciousness and memory models
- Loading branch information
Showing
19 changed files
with
835 additions
and
136 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
class ConsciousnessAttention(nn.Module): | ||
def forward(self, query, key=None, value=None, mask=None): | ||
# Validate inputs | ||
if query.size(0) == 0 or query.size(1) == 0: | ||
raise ValueError("Empty input tensor") | ||
if torch.isnan(query).any(): | ||
raise ValueError("Input contains NaN values") | ||
|
||
# ...existing code... | ||
|
||
class GlobalWorkspace(nn.Module): | ||
def forward(self, x): | ||
# Validate input | ||
if x.size(0) == 0 or x.size(1) == 0: | ||
raise ValueError("Empty input tensor") | ||
if torch.isnan(x).any(): | ||
raise ValueError("Input contains NaN values") | ||
|
||
# ...existing code... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
class ConsciousnessAttention(nn.Module): | ||
def forward(self, x, mask=None): | ||
# Input validation | ||
if x.size(0) == 0 or x.size(1) == 0: | ||
raise ValueError("Empty input tensor") | ||
if torch.isnan(x).any(): | ||
raise ValueError("Input contains NaN values") | ||
|
||
# ...existing code... | ||
|
||
class GlobalWorkspace(nn.Module): | ||
def forward(self, inputs): | ||
# Input validation | ||
if inputs.size(0) == 0 or inputs.size(1) == 0: | ||
raise ValueError("Empty input tensor") | ||
if torch.isnan(inputs).any(): | ||
raise ValueError("Input contains NaN values") | ||
|
||
# ...existing code... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
class InformationIntegration(nn.Module): | ||
def forward(self, inputs, deterministic=True): | ||
"""Process inputs with enhanced validation.""" | ||
# Input tensor validation | ||
if isinstance(inputs, torch.Tensor): | ||
if inputs.size(0) == 0 or inputs.size(1) == 0: | ||
raise ValueError("Empty input dimensions") | ||
if torch.isnan(inputs).any(): | ||
raise ValueError("Input contains NaN values") | ||
if inputs.size(-1) != self.input_dim: | ||
raise ValueError(f"Expected input dimension {self.input_dim}, got {inputs.size(-1)}") | ||
|
||
# Process input after validation | ||
processed = self.input_projection(inputs) | ||
normed = self.layer_norm(processed) | ||
|
||
if not deterministic: | ||
normed = self.dropout(normed) | ||
|
||
# Calculate integration metric (phi) | ||
phi = torch.mean(torch.abs(normed), dim=(-2, -1)) | ||
|
||
return normed, phi |
Oops, something went wrong.