samuelkim314 / deepsymreg Goto Github PK
View Code? Open in Web Editor NEWOfficial repository for the paper "Integration of Neural Network-Based Symbolic Regression in Deep Learning for Scientific Discovery"
Official repository for the paper "Integration of Neural Network-Based Symbolic Regression in Deep Learning for Scientific Discovery"
Hello,
I tried to use the minimal example. It seems it's not working.
First, I received "x_dim" not defined. After I fixed this issue by assigning 100 for x_dim, I received "y" is not defined. So, I moved them to the top of the code. I still receive some errors. Now the error is:
__init__() missing 1 required positional argument: 'learning_rate'
the code is:
import numpy as np
import tensorflow as tf
from utils import functions, pretty_print
from utils.symbolic_network import SymbolicNetL0
from utils.regularization import l12_smooth
funcs = functions.default_func
x_dim = 100
x = np.random.rand(100, 1)
y = x ** 2
# Set up TensorFlow graph for the EQL network
x_placeholder = tf.placeholder(shape=(None, x_dim), dtype=tf.float32)
sym = SymbolicNetL0(symbolic_depth=2, funcs=funcs)
y_hat = sym(x_placeholder)
# Set up loss function with L0.5 loss
mse = tf.losses.mean_squared_error(labels=y, predictions=y_hat)
loss = mse + 1e-2 * l12_smooth(sym.get_weights())
# Set up TensorFlow graph for training
opt = tf.train.RMSPropOptimizer()
train = opt.minimize(loss)
# Random data for a simple function
x = np.random.rand(100, 1)
y = x ** 2
# Training
with tf.Session as sess:
sess.run(tf.global_variables_initializer())
for i in range(1000):
sess.run(train, feed_dict={x_placeholder: x})
# Print out the expression
weights = sess.run(sym.get_weights())
expr = pretty_print.network(weights, funcs, ['x'])
print(expr)
Is the minimal example working?
For example, change
# Initialize weights for last layer (without activation functions)
self.output_weight = tf.Variable(tf.random_uniform(shape=(self.symbolic_layers[-1].n_funcs, 1)))
in symbolic_network.py line 280-281
to
# Initialize weights for last layer (without activation functions)
self.output_weight = tf.Variable(tf.random_uniform(shape=(self.symbolic_layers[-1].n_funcs, 4)))
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.