-
Notifications
You must be signed in to change notification settings - Fork 185
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
finished saving and loading of processed models
- Loading branch information
Showing
6 changed files
with
81 additions
and
33 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
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 |
---|---|---|
@@ -1,23 +1,43 @@ | ||
import random | ||
import numpy as np | ||
from typing import List | ||
|
||
from pyrr import Vector4, Vector3 | ||
from pyrr import Vector4 | ||
|
||
from definitions import vec4wise | ||
from models.node import Node | ||
|
||
|
||
class Edge: | ||
def __init__(self, start_node: Node, end_node: Node, importance: float = None): | ||
self.start_node: Node = start_node | ||
self.end_node: Node = end_node | ||
self.start: Vector4 = Vector4([start_node.position.x, start_node.position.y, start_node.position.z, 1.0]) | ||
self.end: Vector4 = Vector4([end_node.position.x, end_node.position.y, end_node.position.z, 0.0]) | ||
self.initial_data: List[float] = [start_node.position.x, start_node.position.y, start_node.position.z, 1.0, | ||
end_node.position.x, end_node.position.y, end_node.position.z, 0.0] | ||
self.sample_points: List[Vector4] = [self.start, self.end] | ||
if importance is None: | ||
importance = 1.0 # random.random() | ||
self.data: List[float] = [2.0, start_node.output_edges, end_node.input_edges, importance, start_node.data[15], | ||
end_node.data[15], start_node.data[14], end_node.data[14]] | ||
def __init__(self): | ||
self.data: List[float] = [] | ||
self.sample_data: List[float] = [] | ||
|
||
def data_init(self, data: np.array, sample_data: np.array): | ||
self.data = [] | ||
for d in data: | ||
self.data.append(d) | ||
self.sample_data = [] | ||
for sd in sample_data: | ||
self.sample_data.append(sd) | ||
return self | ||
|
||
def importance_init(self, start_node: Node, end_node: Node, layer_id: int, layer_edge_id: int, importance: float): | ||
self.data = [] | ||
self.data = [2.0, layer_id, layer_edge_id, importance, start_node.data[15], end_node.data[15], | ||
start_node.data[14], end_node.data[14]] | ||
self.data.extend(start_node.data[4:14]) | ||
self.data.extend(end_node.data[4:14]) | ||
self.sample_data = [start_node.position.x, start_node.position.y, start_node.position.z, 1.0, | ||
end_node.position.x, end_node.position.y, end_node.position.z, 0.0] | ||
return self | ||
|
||
def random_importance_init(self, start_node: Node, end_node: Node, layer_id: int, layer_edge_id: int): | ||
importance: float = random.random() | ||
self.data = [2.0, layer_id, layer_edge_id, importance, start_node.data[15], end_node.data[15], | ||
start_node.data[14], end_node.data[14]] | ||
self.data.extend(start_node.data[4:14]) | ||
self.data.extend(end_node.data[4:14]) | ||
self.sample_data = [start_node.position.x, start_node.position.y, start_node.position.z, 1.0, | ||
end_node.position.x, end_node.position.y, end_node.position.z, 0.0] | ||
return self |
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