gradient

Computing jacobian matrix in Tensorflow

☆樱花仙子☆ 提交于 2019-12-18 13:48:06
问题 I want to calculate Jacobian matrix by Tensorflow. What I have: def compute_grads(fn, vars, data_num): grads = [] for n in range(0, data_num): for v in vars: grads.append(tf.gradients(tf.slice(fn, [n, 0], [1, 1]), v)[0]) return tf.reshape(tf.stack(grads), shape=[data_num, -1]) fn is a loss function, vars are all trainable variables, and data_num is a number of data. But if we increase the number of data, it takes tremendous time to run the function compute_grads . Any ideas? 回答1: Assuming

Swift: rainbow colour circle

本秂侑毒 提交于 2019-12-18 13:37:57
问题 Hi i am trying to write colour picker in swift that looks like this. But so far I managed this. Draw circle was easy, heres code... fileprivate func setupScene(){ let circlePath: UIBezierPath = UIBezierPath(arcCenter: CGPoint(x: self.wheelView.frame.width/2, y: self.wheelView.frame.height/2), radius: CGFloat(self.wheelView.frame.height/2), startAngle: CGFloat(0), endAngle:CGFloat(Double.pi * 2), clockwise: true) let shapeLayer = CAShapeLayer() shapeLayer.path = circlePath.cgPath //color

Swift: rainbow colour circle

别来无恙 提交于 2019-12-18 13:37:04
问题 Hi i am trying to write colour picker in swift that looks like this. But so far I managed this. Draw circle was easy, heres code... fileprivate func setupScene(){ let circlePath: UIBezierPath = UIBezierPath(arcCenter: CGPoint(x: self.wheelView.frame.width/2, y: self.wheelView.frame.height/2), radius: CGFloat(self.wheelView.frame.height/2), startAngle: CGFloat(0), endAngle:CGFloat(Double.pi * 2), clockwise: true) let shapeLayer = CAShapeLayer() shapeLayer.path = circlePath.cgPath //color

Calculate color HEX having 2 colors and percent/position

我只是一个虾纸丫 提交于 2019-12-18 12:28:30
问题 Is it possible to calculate a color in a middle of a gradient? var color1 = 'FF0000'; var color2 = '00FF00'; // 50% between the two colors, should return '808000' var middle = gradient(color1, color2, 0.5); I only have two hex strings, and I want one in return. 回答1: This should work: It basically involves converting them to decimal, finding the halves, converting the results back to hex and then concatenating them. var color1 = 'FF0000'; var color2 = '00FF00'; var ratio = 0.5; var hex =

How to create gradient object with Raphael

我是研究僧i 提交于 2019-12-18 12:24:34
问题 I was trying to use Raphael JS graphics library. I would like to use the attribute gradient which should accept an object. Documentation says to refer to SVG specs. I found the gradient object in SVG, for instance <linearGradient id="myFillGrad" x1="0%" y1="100%" x2="100%" y2="0%"> <stop offset="5%" stop-color="red" /> <stop offset="95%" stop-color="blue" stop-opacity="0.5" /> </linearGradient> but how can I reference that from within my javascript? circle.attr("gradient", "myFillGrad");

Using a gradientDrawable with more than three colors set

不羁的心 提交于 2019-12-18 12:16:29
问题 According to what I've read, you can use a gradientDrawable and have three colors set for it, for example: <gradient startColor="#00FF00" centerColor="#FFFF00" endColor="#FFFFFF"/> But what if I want more than three colors, and not only that, I want to be able to set where to put each (in weight/percentage)? Is it possible using the API or should I make my own customized drawable? If I need to make my own customized drawable, how should I do it? 回答1: put this code in your onCreate() method:

CSS3 Gradients to reproduce an 'inner glow' effect from Illustrator with border-radius applied

北城余情 提交于 2019-12-18 12:15:21
问题 I am in the process of trying to get my head properly around CSS3 Gradients (specifically radial ones) and in doing so I think I've set myself a relatively tough challenge. In Adobe Illustrator I have created the following 'button' style. To create this image I created a rectangle with a background colour of rgb(63,64,63) or #3F403F , then 'stylized' it to have a 15px border radius. I then applied an 'inner glow' to it with a 25% opacity, 8px blur, white from the center. Finally, I applied a

CSS (perhaps with Compass): Cross-browser gradient

拟墨画扇 提交于 2019-12-18 11:53:39
问题 I would like to get a gradient in CSS (perhaps through Compass) that works in every major browser, including IE7+. Is there an easy way to do this (without writing a lot of code, and without a custom image file)? I looked at Compass's gradient mixin, but it does not work with Internet Explorer. Any ideas? (It does not need to be Compass -- I am happy install something else.) Edit: What I am trying to get is some framework (like Compass?) that generates code like what Blowsie posted that's

How to add a blurred drop shadow to a button?

这一生的挚爱 提交于 2019-12-18 10:36:29
问题 I need to add blurred drop shadow to my button: I tried to create background with layer-list xml drawable, but it not looks like blur. <?xml version="1.0" encoding="utf-8"?> <layer-list xmlns:android="http://schemas.android.com/apk/res/android"> <!-- Drop Shadow Stack --> <item> <shape> <corners android:radius="45dp" /> <padding android:bottom="2dp" android:left="1dp" android:right="1dp" android:top="1dp" /> <stroke android:width="6dp" android:color="#007879E8" /> </shape> </item> ////// 10

Which color gradient is used to color mandelbrot in wikipedia?

主宰稳场 提交于 2019-12-18 10:28:38
问题 At Wikipedia's Mandelbrot set page there are really beautiful generated images of the Mandelbrot set. I also just implemented my own Mandelbrot algorithm. Given n is the number of iterations used to calculate each pixel, I color them pretty simple from black to green to white like that (with C++ and Qt 5.0): QColor mapping(Qt::white); if (n <= MAX_ITERATIONS){ double quotient = (double) n / (double) MAX_ITERATIONS; double color = _clamp(0.f, 1.f, quotient); if (quotient > 0.5) { // Close to