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'
Running the convex.py example with latest tensorflow fails, but works with scs solver.
With TF 0.12.1 the following error: