我正在尝试实施Adversarial NN,它需要在交替训练小批量时"冻结"图形的一个或另一个部分.即有两个子网:G和D.
G( Z ) -> Xz
D( X ) -> Y
Run Code Online (Sandbox Code Playgroud)
其中损失函数G
取决于D[G(Z)], D[X]
.
首先,我需要在D中训练所有G参数固定的参数,然后在G中参数D中的参数固定.第一种情况下的损失函数将是第二种情况下的负损失函数,并且更新将必须应用于第一或第二子网的参数.
我看到张量流有tf.stop_gradient
功能.为了训练D(下游)子网,我可以使用此功能来阻止梯度流
Z -> [ G ] -> tf.stop_gradient(Xz) -> [ D ] -> Y
Run Code Online (Sandbox Code Playgroud)
这tf.stop_gradient
是非常简洁的注释,没有内联示例(例子seq2seq.py
太长而且不容易阅读),但看起来它必须在图形创建期间调用.这是否意味着如果我想在交替批次中阻止/解除阻塞梯度流,我需要重新创建并重新初始化图模型?
也似乎无法阻止流经G(上游)网络的梯度tf.stop_gradient
,对吧?
作为替代方案,我看到可以将变量列表传递给优化器调用opt_op = opt.minimize(cost, <list of variables>)
,如果可以在每个子网的范围内获取所有变量,这将是一个简单的解决方案.可以获得<list of variables>
一个tf.scope吗?
AWS有一个API网关,可以很容易地设置,管理和监控您的API.但是,您可以为资源方法设置的安全授权设置仅限于AWS-IAM(根据我的理解,这是一个内部vpn角色?).
看来,我对这个问题的研究已经指向我建立一个AWS Cognito池,但是当我去配置一个在我的AWS控制台,对供应商的选择是:Amazon
,Facebook
,Google+
,Twitter
,OpenID
,和Custom
.我想,在那种情况下,我会用Custom
?然后将我自己的EC2实例设置为OAuth2身份验证提供程序服务器.
鉴于Oauth2如今如此受欢迎,令我惊讶的是,没有AWS服务.看起来他们已经走了整个OpenId或SAML路线.令我惊讶的是,缺乏有关如何在云中快速设置Oauth2提供程序的指南.
任何帮助,将不胜感激.
如何在C#中使用FTP列出目录内容?
我使用下面的代码用FTP列出目录内容它以XML格式返回结果,但我只想要目录的名称而不是整个内容.
我怎么能这样做?
public class WebRequestGetExample
{
public static void Main ()
{
// Get the object used to communicate with the server.
FtpWebRequest request = (FtpWebRequest)WebRequest.Create("ftp://www.contoso.com/");
request.Method = WebRequestMethods.Ftp.ListDirectoryDetails;
// This example assumes the FTP site uses anonymous logon.
request.Credentials = new NetworkCredential ("anonymous","janeDoe@contoso.com");
FtpWebResponse response = (FtpWebResponse)request.GetResponse();
Stream responseStream = response.GetResponseStream();
StreamReader reader = new StreamReader(responseStream);
Console.WriteLine(reader.ReadToEnd());
Console.WriteLine("Directory List Complete, status {0}", response.StatusDescription);
reader.Close();
response.Close();
}
}
Run Code Online (Sandbox Code Playgroud)
我想在我的网站上使用Jquery Croppie Plugin为我的用户裁剪图像但是我遇到了这个问题我写的代码在Croppie Site中没有显示
这是我的代码
HTML代码
<input type="file" id="upload" value="Choose a file">
<button class="upload-result">Result</button>
<div class="upload-msg">
Upload a file to start cropping
</div>
<div id="upload-demo"></div>
Run Code Online (Sandbox Code Playgroud)
JS代码
$uploadCrop = $('#upload-demo').croppie({
viewport: {
width: 200,
height: 200,
type: 'circle'
},
boundary: {
width: 300,
height: 300
}
});
Run Code Online (Sandbox Code Playgroud)
注意:我已将我的网站链接到jquery,croppie.js和croppie.css
我使用John papa angular style guide我的控制器看起来像:
遵循风格约翰爸爸风格控制器风格指南:
function testController() {
var vm = this;
vm.model = { name: "controllerAs vm test" };
}
Run Code Online (Sandbox Code Playgroud)
我的测试代码如下:
describe('Controller: testController', function () {
beforeEach(module('myApp'));
var testController;
beforeEach(inject(function ($controller) {
scope = {};
testController = $controller('testController', {
});
}));
it('should have vm.model defined and testController.vm.model is equal to controllerAs vm test', function () {
expect(testController.vm).toBeDefined();
expect(testController.vm.model).toBeDefined();
expect(testController.vm.model.name).toEqual("controllerAs vm test");
});
});
Run Code Online (Sandbox Code Playgroud)
结果:
测试失败:结果消息:预期未定义要定义.在堆栈
所以我的问题是我们如何测试vm.model和其他变量呢?我没有在指南中找到适当的指导线:控制器
unit-testing jasmine angularjs angularjs-scope karma-jasmine
我喜欢写在FreeBSD 10.1 C程序实现了一个DTrace使用者使用libdtrace
.
我知道我需要从调用开始dtrace_open()
- 例如我找到了这个旧的演示文稿,但我甚至无法启动,因为没有dtrace.h
安装(仅在系统源代码树中).
安装了共享库,例如/usr/sbin/dtrace
,FreeBSD附带的工具可以充当DTrace使用者,并且此工具链接到/lib/libdtrace.so.2
(通过符号链接指向/usr/lib/libdtrace.so
).
任何基本的例子,包括构建指令(FreeBSD 10.1/clang)都会对我有所帮助.
编写自定义使用者的实际目标是创建一个可在Python和PyPy中使用的基于CFFI的包装器.意思是:上面的C程序只是为了入门,学习然后继续.
CFFI是将PyPy与共享库连接的推荐,现代,高性能方式.
CFFI可用于ABI和API级别.后者需要包含头文件,前者需要声明从lib中使用的东西.
改编自Adam的答案,这是一个适用于FreeBSD 10.1的完整示例.
Makefile
:
all:
cc \
-I /usr/src/cddl/compat/opensolaris/include \
-I /usr/src/cddl/contrib/opensolaris/lib/libdtrace/common/ \
-I /usr/src/sys/cddl/compat/opensolaris \
-I /usr/src/sys/cddl/contrib/opensolaris/uts/common/ \
hello_dtrace.c \
-l dtrace -l proc -l ctf -l elf -l z -l rtld_db -l pthread -l util \
-o hello_dtrace
Run Code Online (Sandbox Code Playgroud)
hello_dtrace.c
:
#include <dtrace.h>
#include <signal.h> …
Run Code Online (Sandbox Code Playgroud) 我已经能够创建一个允许我一次索引多个字符串列的管道,但是我对它们进行了编码,因为与索引不同,编码器不是估算器所以我根本不会根据OneHotEncoder示例调用文档.
import org.apache.spark.ml.feature.{StringIndexer, VectorAssembler,
OneHotEncoder}
import org.apache.spark.ml.Pipeline
val data = sqlContext.read.parquet("s3n://map2-test/forecaster/intermediate_data")
val df = data.select("win","bid_price","domain","size", "form_factor").na.drop()
//indexing columns
val stringColumns = Array("domain","size", "form_factor")
val index_transformers: Array[org.apache.spark.ml.PipelineStage] = stringColumns.map(
cname => new StringIndexer()
.setInputCol(cname)
.setOutputCol(s"${cname}_index")
)
// Add the rest of your pipeline like VectorAssembler and algorithm
val index_pipeline = new Pipeline().setStages(index_transformers)
val index_model = index_pipeline.fit(df)
val df_indexed = index_model.transform(df)
//encoding columns
val indexColumns = df_indexed.columns.filter(x => x contains "index")
val one_hot_encoders: Array[org.apache.spark.ml.PipelineStage] = indexColumns.map(
cname => …
Run Code Online (Sandbox Code Playgroud) 如何更改电话呼叫用户界面?就像我有自己的拨号器布局和联系人布局,但我如何更改调用UI.那么,当呼叫正在进行时,我可以取下扬声器按钮吗?
这是我创建的拨号场景:拨号器图片
但我不知道如何编辑这个屏幕:调用图片
编辑:我已经建立了UI,我只是无法在通话期间显示它!
以下是更简单版本的代码:
public class MainActivity extends Activity {
private Button callBtn;
private Button dialBtn;
private EditText number;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
number = (EditText) findViewById(R.id.phoneNumber);
callBtn = (Button) findViewById(R.id.call);
dialBtn = (Button) findViewById(R.id.dial);
// add PhoneStateListener for monitoring
MyPhoneListener phoneListener = new MyPhoneListener();
TelephonyManager telephonyManager =
(TelephonyManager) this.getSystemService(Context.TELEPHONY_SERVICE);
// receive notifications of telephony state changes
telephonyManager.listen(phoneListener,PhoneStateListener.LISTEN_CALL_STATE);
callBtn.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
try {
// set the data …
Run Code Online (Sandbox Code Playgroud) 当我执行时,我需要安装ruby-debug-base19以便在Netbeans IDE上激活调试:
$ gem install ruby-debug-base19
Run Code Online (Sandbox Code Playgroud)
我收到以下错误.从日志生成中提取
C:/Ruby193/bin/ruby.exe extconf.rb
checking for rb_method_entry_t.body in method.h... no
checking for vm_core.h... no
C:/Ruby193/lib/ruby/gems/1.9.1/gems/ruby_core_source-0.1.5/lib/ruby_core_source.rb:39: Use RbConfig instead of obsolete and deprecated Config.
checking for rb_method_entry_t.body in method.h... no
checking for vm_core.h... yes
checking for iseq.h... yes
checking for insns.inc... yes
checking for insns_info.inc... yes
checking for eval_intern.h... yes
creating Makefile
make
generating ruby_debug-i386-mingw32.def
compiling breakpoint.c
compiling ruby_debug.c
ruby_debug.c:24:19: error: conflicting types for 'rb_iseq_compile_with_option'
C:/Ruby193/include/ruby-1.9.1/ruby-1.9.3-p125/vm_core.h:505:7: note: previous declaration of 'rb_iseq_compile_with_option' was here
ruby_debug.c: In function …
Run Code Online (Sandbox Code Playgroud) 我正在尝试使用来自axis2(版本1.6.1)的wsdl2java生成一个Web服务客户端.
./wsdl2java.sh -uri http://www.ncbi.nlm.nih.gov/entrez/eutils/soap/v2.0/efetch_snp.wsdl
Run Code Online (Sandbox Code Playgroud)
当我打电话给这项服务时,我得到一个例外.
org.apache.axis2.AxisFault: org.apache.axis2.databinding.ADBException: Unexpected subelement {http://www.ncbi.nlm.nih.gov/soap/eutils/efetch_snp}Rs
try {
EFetchSnpServiceStub fetchService = new EFetchSnpServiceStub();
EFetchSnpServiceStub.EFetchRequest reqIdSnp = new EFetchSnpServiceStub.EFetchRequest();
reqIdSnp.setId("193925233");
EFetchSnpServiceStub.EFetchResult resIdSnp = fetchService.run_eFetch(reqIdSnp);
} catch (Exception e) {
System.out.println(e.toString());
}
Run Code Online (Sandbox Code Playgroud)
但是,使用soaptest,我可以在结果中看到Rs Tag.
<Rs rsId="193925233" snpClass="snp" snpType="notwithdrawn" molType="genomic" bitField="050000000005000000000100" taxId="3702">
Run Code Online (Sandbox Code Playgroud)
我该如何解决这个异常?WSDL不在我的控制之下.
.net ×1
amazon-ec2 ×1
amazon-s3 ×1
android ×1
angularjs ×1
apache-spark ×1
axis2 ×1
c ×1
c# ×1
dtrace ×1
exception ×1
freebsd ×1
ftp ×1
html ×1
jasmine ×1
java ×1
javascript ×1
jquery ×1
oauth-2.0 ×1
phone-call ×1
python ×1
ruby-1.9.3 ×1
ruby-debug ×1
scala ×1
tensorflow ×1
unit-testing ×1
web-services ×1
windows ×1