Remove self references to general data. Maybe faster?
Browse files
app.py
CHANGED
@@ -1101,15 +1101,15 @@ class Network(object):
|
|
1101 |
|
1102 |
def __init__(self, structure, weights):
|
1103 |
# Instantiate variables
|
1104 |
-
self.curves = curves
|
1105 |
-
self.new_curves = new_curves
|
1106 |
-
self.geometry = geometry
|
1107 |
-
self.new_geometry = new_geometry
|
1108 |
-
self.S = S
|
1109 |
-
self.N = N
|
1110 |
-
self.D = D
|
1111 |
-
self.F = F
|
1112 |
-
self.G = G
|
1113 |
|
1114 |
# Load network
|
1115 |
with open(structure, 'r') as file:
|
@@ -1120,19 +1120,19 @@ class Network(object):
|
|
1120 |
print(idx)
|
1121 |
|
1122 |
if idx is None:
|
1123 |
-
idx = numpy.random.randint(1,
|
1124 |
else:
|
1125 |
idx = int(idx)
|
1126 |
|
1127 |
# Get the input
|
1128 |
-
data_input =
|
1129 |
-
other_data_input = data_input.reshape((
|
1130 |
|
1131 |
# Get the outputs
|
1132 |
print(data_input.shape)
|
1133 |
predicted_output = self.network.predict(data_input)
|
1134 |
-
true_output =
|
1135 |
-
predicted_output = predicted_output.reshape((3,
|
1136 |
|
1137 |
f = numpy.linspace(0.05, 2.0, 64)
|
1138 |
fd = pandas.DataFrame(f).rename(columns={0: "Frequency"})
|
@@ -1145,9 +1145,8 @@ class Network(object):
|
|
1145 |
|
1146 |
def analysis_from_geometry(self, geometry):
|
1147 |
# Get the outputs
|
1148 |
-
print(numpy.array([geometry.flatten().tolist()]).shape)
|
1149 |
predicted_output = self.network.predict(numpy.array([geometry.flatten().tolist()]))
|
1150 |
-
predicted_output = predicted_output.reshape((3,
|
1151 |
|
1152 |
f = numpy.linspace(0.05, 2.0, 64)
|
1153 |
fd = pandas.DataFrame(f).rename(columns={0: "Frequency"})
|
@@ -1160,18 +1159,18 @@ class Network(object):
|
|
1160 |
print(idx)
|
1161 |
|
1162 |
if idx is None:
|
1163 |
-
idx = numpy.random.randint(1,
|
1164 |
else:
|
1165 |
idx = int(idx)
|
1166 |
|
1167 |
# Get the input
|
1168 |
-
data_input =
|
1169 |
-
other_data_input = data_input.reshape((3,
|
1170 |
|
1171 |
# Get the outputs
|
1172 |
predicted_output = self.network.predict(data_input)
|
1173 |
-
true_output =
|
1174 |
-
predicted_output = predicted_output.reshape((
|
1175 |
|
1176 |
# return idx, other_data_input, true_output, predicted_output
|
1177 |
return predicted_output, true_output
|
@@ -1179,11 +1178,11 @@ class Network(object):
|
|
1179 |
|
1180 |
def synthesis_from_spectrum(self, other_data_input):
|
1181 |
# Get the input
|
1182 |
-
data_input = other_data_input.reshape((1, 3*
|
1183 |
|
1184 |
# Get the outputs
|
1185 |
predicted_output = self.network.predict(data_input)
|
1186 |
-
predicted_output = predicted_output.reshape((
|
1187 |
|
1188 |
# return idx, other_data_input, true_output, predicted_output
|
1189 |
return predicted_output
|
@@ -1191,15 +1190,15 @@ class Network(object):
|
|
1191 |
def get_geometry(self, idx=None):
|
1192 |
|
1193 |
if idx is None:
|
1194 |
-
idx = numpy.random.randint(1,
|
1195 |
else:
|
1196 |
idx = int(idx)
|
1197 |
|
1198 |
idx = int(idx)
|
1199 |
|
1200 |
# Get the input
|
1201 |
-
data_input =
|
1202 |
-
other_data_input = data_input.reshape((
|
1203 |
|
1204 |
# return idx, other_data_input, true_output, predicted_output
|
1205 |
return other_data_input
|
@@ -1208,15 +1207,15 @@ class Network(object):
|
|
1208 |
def get_performance(self, idx=None):
|
1209 |
|
1210 |
if idx is None:
|
1211 |
-
idx = numpy.random.randint(1,
|
1212 |
else:
|
1213 |
idx = int(idx)
|
1214 |
|
1215 |
idx = int(idx)
|
1216 |
|
1217 |
# Get the input
|
1218 |
-
data_input =
|
1219 |
-
other_data_input = data_input.reshape((3,
|
1220 |
|
1221 |
f = numpy.linspace(0.05, 2.0, 64)
|
1222 |
fd = pandas.DataFrame(f).rename(columns={0: "Frequency"})
|
|
|
1101 |
|
1102 |
def __init__(self, structure, weights):
|
1103 |
# Instantiate variables
|
1104 |
+
# self.curves = curves
|
1105 |
+
# self.new_curves = new_curves
|
1106 |
+
# self.geometry = geometry
|
1107 |
+
# self.new_geometry = new_geometry
|
1108 |
+
# self.S = S
|
1109 |
+
# self.N = N
|
1110 |
+
# self.D = D
|
1111 |
+
# self.F = F
|
1112 |
+
# self.G = G
|
1113 |
|
1114 |
# Load network
|
1115 |
with open(structure, 'r') as file:
|
|
|
1120 |
print(idx)
|
1121 |
|
1122 |
if idx is None:
|
1123 |
+
idx = numpy.random.randint(1, S * N)
|
1124 |
else:
|
1125 |
idx = int(idx)
|
1126 |
|
1127 |
# Get the input
|
1128 |
+
data_input = new_geometry[idx:(idx+1), :]
|
1129 |
+
other_data_input = data_input.reshape((G, G, G), order='F')
|
1130 |
|
1131 |
# Get the outputs
|
1132 |
print(data_input.shape)
|
1133 |
predicted_output = self.network.predict(data_input)
|
1134 |
+
true_output = new_curves[idx].reshape((3, F))
|
1135 |
+
predicted_output = predicted_output.reshape((3, F))
|
1136 |
|
1137 |
f = numpy.linspace(0.05, 2.0, 64)
|
1138 |
fd = pandas.DataFrame(f).rename(columns={0: "Frequency"})
|
|
|
1145 |
|
1146 |
def analysis_from_geometry(self, geometry):
|
1147 |
# Get the outputs
|
|
|
1148 |
predicted_output = self.network.predict(numpy.array([geometry.flatten().tolist()]))
|
1149 |
+
predicted_output = predicted_output.reshape((3, F))
|
1150 |
|
1151 |
f = numpy.linspace(0.05, 2.0, 64)
|
1152 |
fd = pandas.DataFrame(f).rename(columns={0: "Frequency"})
|
|
|
1159 |
print(idx)
|
1160 |
|
1161 |
if idx is None:
|
1162 |
+
idx = numpy.random.randint(1, S * N)
|
1163 |
else:
|
1164 |
idx = int(idx)
|
1165 |
|
1166 |
# Get the input
|
1167 |
+
data_input = new_curves[idx:(idx+1), :]
|
1168 |
+
other_data_input = data_input.reshape((3, F))
|
1169 |
|
1170 |
# Get the outputs
|
1171 |
predicted_output = self.network.predict(data_input)
|
1172 |
+
true_output = new_geometry[idx].reshape((G, G, G), order='F')
|
1173 |
+
predicted_output = predicted_output.reshape((G, G, G), order='F')
|
1174 |
|
1175 |
# return idx, other_data_input, true_output, predicted_output
|
1176 |
return predicted_output, true_output
|
|
|
1178 |
|
1179 |
def synthesis_from_spectrum(self, other_data_input):
|
1180 |
# Get the input
|
1181 |
+
data_input = other_data_input.reshape((1, 3*F))
|
1182 |
|
1183 |
# Get the outputs
|
1184 |
predicted_output = self.network.predict(data_input)
|
1185 |
+
predicted_output = predicted_output.reshape((G, G, G), order='F')
|
1186 |
|
1187 |
# return idx, other_data_input, true_output, predicted_output
|
1188 |
return predicted_output
|
|
|
1190 |
def get_geometry(self, idx=None):
|
1191 |
|
1192 |
if idx is None:
|
1193 |
+
idx = numpy.random.randint(1, S * N)
|
1194 |
else:
|
1195 |
idx = int(idx)
|
1196 |
|
1197 |
idx = int(idx)
|
1198 |
|
1199 |
# Get the input
|
1200 |
+
data_input = new_geometry[idx:(idx+1), :]
|
1201 |
+
other_data_input = data_input.reshape((G, G, G), order='F')
|
1202 |
|
1203 |
# return idx, other_data_input, true_output, predicted_output
|
1204 |
return other_data_input
|
|
|
1207 |
def get_performance(self, idx=None):
|
1208 |
|
1209 |
if idx is None:
|
1210 |
+
idx = numpy.random.randint(1, S *N)
|
1211 |
else:
|
1212 |
idx = int(idx)
|
1213 |
|
1214 |
idx = int(idx)
|
1215 |
|
1216 |
# Get the input
|
1217 |
+
data_input = new_curves[idx:(idx+1), :]
|
1218 |
+
other_data_input = data_input.reshape((3, F))
|
1219 |
|
1220 |
f = numpy.linspace(0.05, 2.0, 64)
|
1221 |
fd = pandas.DataFrame(f).rename(columns={0: "Frequency"})
|