我有一个机器学习模型,其中模型参数的梯度是解析的,不需要自动微分。然而,我仍然希望能够利用 Flux 中的不同优化器,而不必依赖 Zygote 进行区分。这是我的代码的一些片段。
\n\nW = rand(Nh, N)\nU = rand(N, Nh)\nb = rand(N)\nc = rand(Nh)\n\n\xce\xb8 = Flux.Params([b, c, U, W])\n\nopt = ADAM(0.01)\nRun Code Online (Sandbox Code Playgroud)\n\n然后我有一个函数可以计算模型参数的解析梯度,\xce\xb8。
function gradients(x) # x = one input data point or a batch of input data points\n # stuff to calculate gradients of each parameter\n # returns gradients of each parameter\nRun Code Online (Sandbox Code Playgroud)\n\n然后我希望能够做如下的事情。
\n\ngrads = gradients(x)\nupdate!(opt, \xce\xb8, grads)\nRun Code Online (Sandbox Code Playgroud)\n\n我的问题是:我的函数需要返回什么形式/类型gradient(x)才能执行此操作update!(opt, \xce\xb8, grads),以及如何执行此操作?
我收到错误
dry-run failed, reason: Invalid, error: Deployment.apps "server" is invalid: spec.template.spec.containers[0].env[0].valueFrom: Invalid value:
"": may not be specified when `value` is not empty
Run Code Online (Sandbox Code Playgroud)
当尝试使用以下命令覆盖Flux Kustomization中的值时patchesStrategicMerge:
env:
- name: DATABASE_URL
valueFrom:
secretKeyRef:
name: server-db-url
key: dburl
Run Code Online (Sandbox Code Playgroud)
秘密server-db-url存在并包含密钥dburl
我不确定这是否与https://github.com/kubernetes/kubernetes/issues/46861有关
我使用 spring Reactor 库编写了一个逻辑,以异步模式获取所有操作员,然后获取每个操作员的所有设备(分页)。
创建一个 Flux 来获取所有运算符,然后订阅它。
final Flux<List<OperatorDetails>> operatorDetailsFlux = reactiveResourceProvider.getOperators();
operatorDetailsFlux
.subscribe(operatorDetailsList -> {
for (final OperatorDetails operatorDetails : operatorDetailsList) {
getAndCacheDevicesForOperator(operatorDetails.getId());
}
});
Run Code Online (Sandbox Code Playgroud)
现在,对于每个运营商,我正在获取需要多个订阅才能获取设备 mono 的设备,该设备通过订阅 MONO 来异步获取所有页面。
private void getAndCacheDevicesForOperator(final int operatorId) {
Mono<DeviceListResponseEntity> deviceListResponseEntityMono = reactiveResourceProvider.getConnectedDeviceMonoWithRetryAndErrorSpec(
operatorId, 0);
deviceListResponseEntityMono.subscribe(deviceListResponseEntity -> {
final PaginatedResponseEntity PaginatedResponseEntity = deviceListResponseEntity.getData();
final long totalDevicesInOperator = PaginatedResponseEntity.getTotalCount();
int deviceCount = PaginatedResponseEntity.getCount();
while (deviceCount < totalDevicesInOperator) {
final Mono<DeviceListResponseEntity> deviceListResponseEntityPageMono = reactiveResourceProvider.getConnectedDeviceMonoWithRetryAndErrorSpec(
operatorId, deviceCount);
deviceListResponseEntityPageMono.subscribe(deviceListResponseEntityPage -> {
final List<DeviceDetails> deviceDetailsList = deviceListResponseEntityPage.getData() …Run Code Online (Sandbox Code Playgroud) 简短的问题:看起来应用程序的状态可以完全从React/Flux商店序列化.我已经看到了输入值和其他东西,但动画或悬停效果是什么?我是否应该使用经典的:hoverCSS选择器来悬停效果,还是应该使用mouseenter和-leave事件并在我的商店中保存悬停状态?
我看到Flux架构和React项目经常提到的术语.
据我所知,这是一种设计模式,但我无法在网上找到它的好描述.
我一直在寻找normalizr来展平以标准JSON API格式格式化的JSON API数据.谁能指点我这样做的一些例子?我特别想知道如何处理资源对象关系的normalizr模式(由JSON API标准定义).在JSON API标准中,在资源对象中定义了"relationships"属性,然后是每组相关对象的属性.以下是JSON API格式的单个产品类别的示例,其中包含两个相关产品:
{
"jsonapi": {
"version": "1.0"
},
"meta": {
"time": "0.006"
},
"data": [
{
"type": "category",
"id": "6",
"attributes": {
"name": "Odwalla"
},
"meta": {
"product_count": "0"
},
"relationships": {
"product": {
"data": [
{
"type": "product",
"id": "4785"
},
{
"type": "product",
"id": "4786"
}
]
}
}
}
],
"included": [
{
"type": "product",
"id": "4786",
"attributes": {
"name": "Strawberry & Banana Odwalla",
"description": null,
"price": "3.19",
"upc": …Run Code Online (Sandbox Code Playgroud) 我正在尝试在我的React + Flux项目中包含一个JointJS图.我从那里现有的演示开始.
我的想法是将图表嵌入一个更高级别的组件中,该组件将在我的项目中重用.
我想出的结构如下:
index.html
...
<body>
<section id="mySec"></section>
...
Run Code Online (Sandbox Code Playgroud)
app.js
...
ReactDOM.render(
<JointJSDiagram id="1"/>,
document.getElementById('mySec')
);
Run Code Online (Sandbox Code Playgroud)
JointJSDiagram.react.js
...
var JointJSDiagramStore = require('../stores/JointJSDiagramStore');
class JointJSDiagram extends React.Component {
...
componentDidMount() {
var el = this.refs[this.props.placeHolder];
document.addEventListener("DOMContentLoaded", function(elt){
return function(){JointJSDiagramStore.buildDiagram(elt)};
}(el), false);
}
...
render() {
return (<div ref={this.props.placeHolder}/>);
}
...
}
module.exports = JointJSDiagram;
Run Code Online (Sandbox Code Playgroud)
JointJSDiagramStore.js
...
var AppDispatcher = require('../dispatcher/AppDispatcher');
var EventEmitter = require('events').EventEmitter;
var assign = require('object-assign');
var _graph = new joint.dia.Graph();
var _paper = new …Run Code Online (Sandbox Code Playgroud) 我正在编写一个react + flux应用程序,我已经将IdentityServer设置为OpenID Connect提供程序.IdentityServer人员提供了两个库,使得处理客户端变得更加容易.
这些库是oidc-client和oidc-token-manager
我想使用其中的一个,但我在思考如何将它们与flux结构一起使用时遇到了一些麻烦.
您是否有使用这些库或IdentityServer通常使用react + flux应用程序的经验?
有必须比我在我的haribranedness正在做一个更好的办法
<.div(
ApplicationCircuit.zoom(_.posts.postList).value.map {
case p: Post ?
ApplicationCircuit.connect(_.posts.postList.filterNot(x ? x == p).head)(x ? PostItemC(PostItemC.Props(x)))
}
)
Run Code Online (Sandbox Code Playgroud)
这是一个奇怪的问题,但我有我的理由.当我Post从ModelProxy[Posts]哪里渲染时case class Posts(seq: Seq[Post]),我想代替ModelProxy[Post]每个渲染一个代理.这将允许我继续前进,将其包装在一起Pot,然后Post轻松处理各个更新,删除等.
我无法finagling对象变成这种形式,虽然,但我觉得有这么多zoomFlatMap和zoomFlatMapRW等的东西应该帮助我从我到那里从哪里得到.那就是说,我迷路了.
我最近的尝试
<.div(
ApplicationCircuit.zoom(_.posts.postList).value.map {
case p: Post ?
ApplicationCircuit.connect(_.posts.postList.filterNot(x ? x == p).head)(_.)
}
Run Code Online (Sandbox Code Playgroud)
即 ApplicationCircuit.connect(_.posts.postList)(proxy ? ModelProxy(????))
object ApplicationCircuit
extends Circuit[ApplicationModel]
with ReactConnector[ApplicationModel] {
addProcessor(new DiodeLogger[ApplicationModel]())
override protected def initialModel: ApplicationModel = ApplicationModel(
Posts(Seq()),
Masthead(NavigationItems(Seq()), "JustinTampa", "JustinTampa.com", active …Run Code Online (Sandbox Code Playgroud) 我的简单反应代码是:
main.js:
var ReactDom = require('react-dom');
var Main = React.createClass({
render: function(){
return(
<div>
<a onClick={alert("hello world")} >hello</a>
</div>
)
}
});
Run Code Online (Sandbox Code Playgroud)
在控制台中有一个错误:
TypeError:listener必须是一个函数
错误:
在运行此代码时,我正在获取该警报功能,而不是这应该是单击功能.
注意:我使用的是flux结构,但在给定的文件中没有填充数据.
提前致谢
flux ×10
reactjs ×6
api ×1
java ×1
javascript ×1
jointjs ×1
json ×1
julia ×1
kubernetes ×1
react-jsx ×1
reactjs-flux ×1
redux ×1
scala.js ×1
spring-boot ×1