mirror of
https://github.com/Cian-H/symbolic_nn_tests.git
synced 2025-12-22 22:22:01 +00:00
Added a garbage semantic function
Added a semantic function where the injected "knowledge" is just random garbage. This function was written to isolate the "knowledge" component of the other semantic functions, basically to ensure it's the matrices and not the rest of the process that is making the difference in training.
This commit is contained in:
@@ -31,6 +31,7 @@ def main():
|
|||||||
run_test(semantic_loss.hasline_cross_entropy, "hasline_cross_entropy")
|
run_test(semantic_loss.hasline_cross_entropy, "hasline_cross_entropy")
|
||||||
run_test(semantic_loss.hasloop_cross_entropy, "hasloop_cross_entropy")
|
run_test(semantic_loss.hasloop_cross_entropy, "hasloop_cross_entropy")
|
||||||
run_test(semantic_loss.multisemantic_cross_entropy, "multisemantic_cross_entropy")
|
run_test(semantic_loss.multisemantic_cross_entropy, "multisemantic_cross_entropy")
|
||||||
|
run_test(semantic_loss.garbage_cross_entropy, "garbage_cross_entropy")
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|||||||
@@ -73,3 +73,11 @@ MULTISEMANTIC_MATRIX = SIMILARITY_MATRIX * HASLINE_MATRIX * HASLOOP_MATRIX
|
|||||||
MULTISEMANTIC_MATRIX /= MULTISEMANTIC_MATRIX.sum()
|
MULTISEMANTIC_MATRIX /= MULTISEMANTIC_MATRIX.sum()
|
||||||
|
|
||||||
multisemantic_cross_entropy = create_semantic_cross_entropy(MULTISEMANTIC_MATRIX)
|
multisemantic_cross_entropy = create_semantic_cross_entropy(MULTISEMANTIC_MATRIX)
|
||||||
|
|
||||||
|
# NOTE: As a final test, lets make something similar to tehse but where there's no knowledge,
|
||||||
|
# just random data. This will create a benchmark for the effects of this process wothout the
|
||||||
|
# "knowledge" component
|
||||||
|
GARBAGE_MATRIX = torch.rand(10, 10).to("cuda")
|
||||||
|
GARBAGE_MATRIX /= GARBAGE_MATRIX.sum()
|
||||||
|
|
||||||
|
garbage_cross_entropy = create_semantic_cross_entropy(GARBAGE_MATRIX)
|
||||||
|
|||||||
Reference in New Issue
Block a user