journal_basins.py debugged II
Questions for functionalities_test.py corrected some fixes Redo and implementation of everything path related now using pathlib.Path
This commit is contained in:
@ -37,6 +37,8 @@ def is_identity_function(network: Net, epsilon=pow(10, -5)) -> bool:
|
||||
|
||||
|
||||
def is_zero_fixpoint(network: Net, input_data: Tensor, epsilon=pow(10, -5)) -> bool:
|
||||
# FIXME: Is the the correct test?
|
||||
raise NotImplementedError
|
||||
result = overall_fixpoint_test(network, epsilon, input_data)
|
||||
|
||||
return result
|
||||
@ -50,6 +52,7 @@ def is_secondary_fixpoint(network: Net, input_data: Tensor, epsilon: float) -> b
|
||||
first_output = network(input_data)
|
||||
|
||||
# Getting the second output by initializing a new net with the weights of the original net.
|
||||
# FixMe: Is this correct? I Think it should be the same function thus the same network
|
||||
net_copy = copy.deepcopy(network)
|
||||
net_copy.apply_weights(first_output)
|
||||
input_data_2 = net_copy.input_weight_matrix()
|
||||
@ -57,18 +60,18 @@ def is_secondary_fixpoint(network: Net, input_data: Tensor, epsilon: float) -> b
|
||||
# Calculating second output
|
||||
second_output = network(input_data_2)
|
||||
|
||||
check_smaller_epsilon = all(epsilon > second_output)
|
||||
check_greater_epsilon = all(-epsilon < second_output)
|
||||
# Perform the Check:
|
||||
check_abs_within_epsilon = all(epsilon > abs(input_data - second_output))
|
||||
|
||||
if check_smaller_epsilon and check_greater_epsilon:
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
# FIXME: This is wrong, is it?
|
||||
# check_smaller_epsilon = all(epsilon > second_output)
|
||||
# check_greater_epsilon = all(-epsilon < second_output)
|
||||
|
||||
return True if check_abs_within_epsilon else False
|
||||
|
||||
|
||||
def is_weak_fixpoint(network: Net, input_data: Tensor, epsilon: float) -> bool:
|
||||
result = overall_fixpoint_test(network, epsilon, input_data)
|
||||
|
||||
return result
|
||||
|
||||
|
||||
@ -80,7 +83,6 @@ def test_for_fixpoints(fixpoint_counter: Dict, nets: List, id_functions=None):
|
||||
for i in range(len(nets)):
|
||||
net = nets[i]
|
||||
input_data = net.input_weight_matrix()
|
||||
target_data = net.create_target_weights(input_data)
|
||||
|
||||
if is_divergent(nets[i]):
|
||||
fixpoint_counter["divergent"] += 1
|
||||
@ -104,5 +106,6 @@ def test_for_fixpoints(fixpoint_counter: Dict, nets: List, id_functions=None):
|
||||
|
||||
return id_functions
|
||||
|
||||
|
||||
def changing_rate(x_new, x_old):
|
||||
return x_new - x_old
|
||||
|
Reference in New Issue
Block a user