cvxflow's People
Forkers
0xkayvan ml-ai-nlp-ir minvex arnocandel waldstein1983 den-run-ai ramakumar1729 csamal1403 panyao vishalbelsare ricklentz thvhauwe yueyedeai marjann92 vinace agamtomar anna-xu953 fagan2888 kai0511 jiaodaxiaozi utjfritzcvxflow's Issues
Really cool idea
๐
not compatible with TF 0.12+, only works on TF 0.11
Running the convex.py example with latest tensorflow fails, but works with scs solver.
#if __name__ == "__main__":
_, run_name, prob_name, n_str = "dummy", "tensorflow", "lasso_dense", "1000" #sys.argv
run = globals()["run_" + run_name]
prob = globals()[prob_name]
n = int(n_str)
print "running", run_name, prob_name, n
np.random.seed(0)
run(prob(n))
print
print
running tensorflow lasso_dense 1000
TypeErrorTraceback (most recent call last)
<ipython-input-11-1b32d471257e> in <module>()
7 print "running", run_name, prob_name, n
8 np.random.seed(0)
----> 9 run(prob(n))
10 print
11 print
<ipython-input-9-783589e4c150> in run_tensorflow(prob)
4
5 t0 = time.time()
----> 6 t_prob = TensorProblem(prob)
7 print "problem_time:", time.time() - t0
8
/home/nbuser/anaconda2_410/lib/python2.7/site-packages/cvxflow/problem.pyc in __init__(self, cvx_problem)
56 self.sym_data.constr_map[s.LEQ])
57
---> 58 self.A_exprs, self.b = get_constraint_tensors(self.constraints)
59 self.c = get_objective_tensor(self.var_ids, self.sym_data)
60
/home/nbuser/anaconda2_410/lib/python2.7/site-packages/cvxflow/problem.pyc in get_constraint_tensors(constraints)
28 b = vstack(
29 [vec(tf.constant(-tree_mat.mul(constr.expr, {}), dtype=tf.float32))
---> 30 for constr in constraints])
31 return A_exprs, b
32
/home/nbuser/anaconda2_410/lib/python2.7/site-packages/cvxflow/tf_util.pyc in vstack(xs)
15
16 def vstack(xs):
---> 17 return tf.concat(0, xs)
/home/nbuser/anaconda2_410/lib/python2.7/site-packages/tensorflow/python/ops/array_ops.pyc in concat(values, axis, name)
1059 ops.convert_to_tensor(axis,
1060 name="concat_dim",
-> 1061 dtype=dtypes.int32).get_shape(
1062 ).assert_is_compatible_with(tensor_shape.scalar())
1063 return identity(values[0], name=scope)
/home/nbuser/anaconda2_410/lib/python2.7/site-packages/tensorflow/python/framework/ops.pyc in convert_to_tensor(value, dtype, name, preferred_dtype)
609 name=name,
610 preferred_dtype=preferred_dtype,
--> 611 as_ref=False)
612
613
/home/nbuser/anaconda2_410/lib/python2.7/site-packages/tensorflow/python/framework/ops.pyc in internal_convert_to_tensor(value, dtype, name, as_ref, preferred_dtype)
674
675 if ret is None:
--> 676 ret = conversion_func(value, dtype=dtype, name=name, as_ref=as_ref)
677
678 if ret is NotImplemented:
/home/nbuser/anaconda2_410/lib/python2.7/site-packages/tensorflow/python/framework/constant_op.pyc in _constant_tensor_conversion_function(v, dtype, name, as_ref)
119 as_ref=False):
120 _ = as_ref
--> 121 return constant(v, dtype=dtype, name=name)
122
123
/home/nbuser/anaconda2_410/lib/python2.7/site-packages/tensorflow/python/framework/constant_op.pyc in constant(value, dtype, shape, name, verify_shape)
100 tensor_value = attr_value_pb2.AttrValue()
101 tensor_value.tensor.CopyFrom(
--> 102 tensor_util.make_tensor_proto(value, dtype=dtype, shape=shape, verify_shape=verify_shape))
103 dtype_value = attr_value_pb2.AttrValue(type=tensor_value.tensor.dtype)
104 const_tensor = g.create_op(
/home/nbuser/anaconda2_410/lib/python2.7/site-packages/tensorflow/python/framework/tensor_util.pyc in make_tensor_proto(values, dtype, shape, verify_shape)
374 nparray = np.empty(shape, dtype=np_dt)
375 else:
--> 376 _AssertCompatible(values, dtype)
377 nparray = np.array(values, dtype=np_dt)
378 # check to them.
/home/nbuser/anaconda2_410/lib/python2.7/site-packages/tensorflow/python/framework/tensor_util.pyc in _AssertCompatible(values, dtype)
300 else:
301 raise TypeError("Expected %s, got %s of type '%s' instead." %
--> 302 (dtype.name, repr(mismatch), type(mismatch).__name__))
303
304
TypeError: Expected int32, got list containing Tensors of type '_Message' instead.
With TF 0.12.1 the following error:
running tensorflow nn_deconv 100
problem_time: 0.0250520706177
WARNING:tensorflow:tf.op_scope(values, name, default_name) is deprecated, use tf.name_scope(name, default_name, values)
AttributeErrorTraceback (most recent call last)
<ipython-input-10-5e016df505f8> in <module>()
7 print "running", run_name, prob_name, n
8 np.random.seed(0)
----> 9 run(prob(n))
10 print
11 print
<ipython-input-9-783589e4c150> in run_tensorflow(prob)
13
14 t0 = time.time()
---> 15 objective = scs_tf.solve(t_prob, equil_iters=50, max_iters=2500, gpu=False)
16 print "cpu_solve_time: %.2f secs" % (time.time() - t0)
17 print "objective: %.2e" % objective
/home/nbuser/anaconda2_410/lib/python2.7/site-packages/cvxflow/scs_tf.pyc in solve(problem, max_iters, trace, eps_primal, eps_dual, eps_gap, equil_iters, gpu)
157 eps_gap=1e-3, equil_iters=50, gpu=True):
158 """Create SCS tensorflow graph and solve."""
--> 159 scaled_problem = ScaledTensorProblem(problem, equil_iters)
160
161 # variables
/home/nbuser/anaconda2_410/lib/python2.7/site-packages/cvxflow/scs_tf.pyc in __init__(self, orig, equil_iters)
29 shape = (int(self.orig.b.get_shape()[0]),
30 int(self.orig.c.get_shape()[0]))
---> 31 d, e = balance(self.orig.A, self.orig.AT, shape, equil_iters)
32 equil_sess = tf.Session()
33 with equil_sess.as_default():
/home/nbuser/anaconda2_410/lib/python2.7/site-packages/cvxflow/equilibrate.pyc in balance(A, AT, shape, iters, name, seed)
19 d += tf.square(A(s))
20 tmp = tf.sqrt(d/iters)
---> 21 d = alpha*tf.inv(project(tmp, 1e-3, 1e3))
22 e = tf.zeros((n, 1))
23 for i in range(iters):
AttributeError: 'module' object has no attribute 'inv'
tried updating to handle TF 1.1 under Python3 v3.6 on Windows
changes "concat" arg order, "reverse" axis list, "pack" -> "stack" and "mul" to "scalar_mul" were necessary
C:\Users\tatli\Downloads\WinPython-64bit-3.6.0.1Qt5b5\scripts>python c:\Users\tatli\cvxflow\cvxflow\problem_test.py
......
----------------------------------------------------------------------
Ran 6 tests in 0.428s
OK
license? Apache?
could not find your license anywhere, is this something you decided?
KeyError: 'tensor_index'
ts=4
ratecon = np.array([6,4,10,0])
tanklim = np.array([10,8,10,6])
ratelim = np.array([4,6,4,6])
tanklevinit = 4
ratemin = 2
rateinj = Variable(ts)
tanklev = Variable(ts)
states = []
for t in range(1,ts):
states.append(tanklev[t]-tanklev[t-1] == rateinj[t] - ratecon[t])
planner = Problem(Minimize(sum_entries(tanklev)),
[tanklev[0] == tanklevinit,
rateinj >= ratemin,
rateinj <= ratelim,
tanklev >= 0,
tanklev <= tanklim
]+states)
planner.solve(verbose=True)
t_prob = TensorProblem(planner)
objective = scs_tf.solve(t_prob, equil_iters=50, max_iters=2500, gpu=False)
WARNING:tensorflow:tf.op_scope(values, name, default_name) is deprecated, use tf.name_scope(name, default_name, values)
KeyErrorTraceback (most recent call last)
<ipython-input-8-4f71c8397e03> in <module>()
1 t_prob = TensorProblem(planner)
----> 2 objective = scs_tf.solve(t_prob, equil_iters=50, max_iters=2500, gpu=False)
/home/nbuser/anaconda2_410/lib/python2.7/site-packages/cvxflow/scs_tf.pyc in solve(problem, max_iters, trace, eps_primal, eps_dual, eps_gap, equil_iters, gpu)
157 eps_gap=1e-3, equil_iters=50, gpu=True):
158 """Create SCS tensorflow graph and solve."""
--> 159 scaled_problem = ScaledTensorProblem(problem, equil_iters)
160
161 # variables
/home/nbuser/anaconda2_410/lib/python2.7/site-packages/cvxflow/scs_tf.pyc in __init__(self, orig, equil_iters)
29 shape = (int(self.orig.b.get_shape()[0]),
30 int(self.orig.c.get_shape()[0]))
---> 31 d, e = balance(self.orig.A, self.orig.AT, shape, equil_iters)
32 equil_sess = tf.Session()
33 with equil_sess.as_default():
/home/nbuser/anaconda2_410/lib/python2.7/site-packages/cvxflow/equilibrate.pyc in balance(A, AT, shape, iters, name, seed)
17 for i in range(iters):
18 s = random_probe((n, 1))
---> 19 d += tf.square(A(s))
20 tmp = tf.sqrt(d/iters)
21 d = alpha*tf.inv(project(tmp, 1e-3, 1e3))
/home/nbuser/anaconda2_410/lib/python2.7/site-packages/cvxflow/problem.pyc in A(self, x)
65 idx = slice(var_offset, var_offset+var_size[0]*var_size[1])
66 xs[var_id] = mat(x[idx,:], var_size)
---> 67 return vstack([vec(cvxpy_expr.tensor(Ai, xs)) for Ai in self.A_exprs])
68
69 def AT(self, y):
/home/nbuser/anaconda2_410/lib/python2.7/site-packages/cvxflow/cvxpy_expr.pyc in tensor(lin_op, value_map)
26 def tensor(lin_op, value_map={}):
27 f_name = "tensor_" + lin_op.type
---> 28 return globals()[f_name](lin_op, value_map)
29
30 def tensor_mul(lin_op, value_map):
/home/nbuser/anaconda2_410/lib/python2.7/site-packages/cvxflow/cvxpy_expr.pyc in tensor_sum(lin_op, value_map)
41 if len(lin_op.args) == 1:
42 # special case for single arg sum
---> 43 return tensor(lin_op.args[0], value_map)
44
45 return tf.add(
/home/nbuser/anaconda2_410/lib/python2.7/site-packages/cvxflow/cvxpy_expr.pyc in tensor(lin_op, value_map)
26 def tensor(lin_op, value_map={}):
27 f_name = "tensor_" + lin_op.type
---> 28 return globals()[f_name](lin_op, value_map)
29
30 def tensor_mul(lin_op, value_map):
KeyError: 'tensor_index'
More Documentation?
I think this project is pretty cool, but it lacks detailed documentation. It would help a lot if you can provide a detailed README about this package.
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ๐๐๐
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.