def call(self, input, training=False): weyl_base = weyl(input) p, E = input # selecting the right potential p = p[:,:,self.pchoice[0]:self.pchoice[1]] # reshape E to have the same shape as p resized_E = (E[:,:,tf.newaxis]+0*p) resized_E = resized_E[:,:,:1] p = tf.concat([p, resized_E], axis=2) #print(0, p.shape) p = self.decider(p, training=training) #print(1, p.shape) out = [self.conv_down(model(p, training=training)[:,0,:]) for model in self.counters] p = tf.concat(out, axis=1) #print(2, p.shape) #print(p.shape) box_size = tf.minimum(1/tf.math.sqrt(E), 10000) E = tf.concat([E, box_size], axis=1) #print(3, E.shape) E = self.weighters(E, training=training) #print(4, E.shape) #print(E.shape) p = p*E #print(5, p.shape) p = self.out_layer(p) return tf.nn.softplus(weyl_base + p)
def call(self, input, training=False): weyl_base = weyl(input) p, E = input # selecting the right potential p = p[:,:,self.pchoice[0]:self.pchoice[1]] # reshape E to have the same shape as p resized_E = (E[:,:,tf.newaxis]+0*p) resized_E = resized_E[:,:,:1] # pE = p and E pE = tf.concat([p, resized_E], axis=2) # compute features - this is the F(dW, W) in front of \int f_{FD}' p = self.res(p)+p p = self.emb(p, training=training) # conv down potential pE = self.conv1(pE) # features as weight * conved down potential = F(dW, W) \int f_{FD}'' #print(p.shape, pE.shape) p = pE*p # weighted sum = integration p = self.weighters(p, training=training) pp = self.out_layer1(p) p = self.out_layer2(pp)+p # residual layer #print(p.shape) return tf.nn.softplus(weyl_base + p)
def call(self, input): weyl_base = weyl(input) p, E = input # selecting the right potential p = p[:, :, self.pchoice[0]] p = p - E p = self.out_layer(p) return tf.nn.softplus(weyl_base + p)
def call(self, input): weyl_base = weyl(input) p, E = input # selecting the right potential p = p[:, :, self.pchoice[0]:self.pchoice[1]] E = E[:, :, tf.newaxis] E = 0.0 * p + E p = tf.concat([p, E], axis=2) p = self.internal(p) return tf.nn.softplus(weyl_base + p)
def call(self, input, training=False): p, E = input weyl_base = weyl((p, E)) # selecting the right potential # p.shape = batch_size x 1 x domain_size x channel_size p = p[:, tf.newaxis, :, self.pchoice[0]:self.pchoice[1]] # reshape E to have the same shape as p # resized_E.shape = batch_size x 1 x domain_sze x 1 resized_E = (E[:, tf.newaxis, :, tf.newaxis] + 0 * p)[:, :, :, :1] #resized_E = resized_E[:,:,:1,:] T = np.arange(self.momentum_size) / (self.momentum_size - 1) T = T.reshape(1, self.momentum_size, 1, 1) T = T**2 T = T * self.momentum_max # phase space Hamiltonian p = T + p - resized_E p = self.decider(p, training=training) #print(1, p.shape) out = [ self.conv_down(model(p, training=training)[:, 0, 0, :]) for model in self.counters ] p = tf.concat(out, axis=1) #print(2, p.shape) #print(p.shape) box_size = tf.minimum(1 / tf.math.sqrt(E), 10000) E = tf.concat([E, box_size], axis=1) #print(3, E.shape) E = self.weighters(E, training=training) #print(4, E.shape) #print(E.shape) p = p * E #print(5, p.shape) p = self.out_layer(p) res = tf.nn.softplus(weyl_base + p) print(res.shape) return res
def plot_model_pred(model, data_set_name, index, data_folder_path="data"): p, E, target = load_data_set_(data_folder_path, data_set_name, [index]) d = {} info_file = os.path.join(data_folder_path, data_set_name + "_" + str(index) + "_info.txt") with open(info_file) as f: line = f.readline() while line: k, v = line.split(':', 1) d[k] = v line = f.readline() #print(nve[:,0].shape, nve[:,1].shape) fig = plt.figure(figsize=(18, 16), dpi=50, facecolor='w', edgecolor='k') plt.scatter(E, target, color="blue", label="True Eigenvalue counting") weyl_base = weyl((p, E)).numpy().astype(np.float32) #print('weyl shape', weyl_base.shape) plt.scatter(E, weyl_base, color="gray", label="Prediction by weyl's law") pred = model((p, E)) #print('pred shape', pred.shape) plt.scatter(E, pred, color="orange", label="Prediction by {}".format(model.name)) #print(d) subtitle = "" for k in d: if k != 'potential type': subtitle += k + ":" + d[k].rstrip('\n') + '; ' plt.title(subtitle) plt.suptitle(d['potential type'], fontsize=14, fontweight='bold') plt.xlabel("Energy") plt.ylabel("Eigenvalue Count") plt.show()
def call(self, input): weyl_base = weyl(input) p, E = input p = tf.concat([p, p - E[:, :, tf.newaxis]], axis=2) #print(0, p.shape) p = self.decider(p) #print(1, p.shape) out = [self.conv_down(model(p)[:, 0, :]) for model in self.counters] p = tf.concat(out, axis=1) #print(2, p.shape) box_size = tf.minimum(1 / tf.math.sqrt(E), 10000) E = tf.concat([E, box_size], axis=1) #print(3, E.shape) E = self.weighters(E) #print(4, E.shape) p = p * E #print(5, p.shape) p = self.out_layer(p) #print(p.shape) return tf.nn.relu(weyl_base + p)