小编cap*_*ono的帖子

将 cuDNN 内核用于 LSTM

我想使用 Cudnn 训练我的 RNN 模型:

max_length <- 140 
embedding_dim <- 128

model <- keras_model_sequential()

# define model
model %>% 
  # layer input
  layer_embedding(
    name = "input",
    input_dim = num_words,
    input_length = max_length,
    output_dim = embedding_dim, 
    embeddings_initializer = initializer_random_uniform(minval = -0.05, maxval = 0.05, seed = 2)
  ) %>%
  # layer dropout
  layer_spatial_dropout_1d(
    name = "embedding_dropout",
    rate = 0.2
  ) %>%
  # layer lstm 1
  bidirectional(layer_lstm(
    name = "lstm",
    units = 64,
    unroll = FALSE,
    dropout = 0.2,
    use_bias = TRUE, …
Run Code Online (Sandbox Code Playgroud)

r keras tensorflow

19
推荐指数
1
解决办法
1万
查看次数

在组件vuejs之外访问存储

我有一个用于配置OpenID Connect身份验证的文件

export const authMgr = new Oidc.UserManager({
  userStore: new Oidc.WebStorageStateStore(),
  authority: **appsetting.oidc**
})
Run Code Online (Sandbox Code Playgroud)

我想访问我的状态以获得appsetting的价值.

我这样做了:

import store from './store'

const appsetting = () => store.getters.appsetting
Run Code Online (Sandbox Code Playgroud)

但我的appsetting总是返回undefined

我错过了什么?

商店:

app.js

const state = {
  appsetting: appsetting,
}

export {
  state 
}
Run Code Online (Sandbox Code Playgroud)

getters.js

const appsetting = state => state.appsetting

export {
  appsetting
}
Run Code Online (Sandbox Code Playgroud)

index.js

export default new Vuex.Store({
  actions,
  getters,
  modules: {
    app
  },
  strict: debug,
  plugins: [createLogger]
})
Run Code Online (Sandbox Code Playgroud)

当我打印值时store.getters,它返回:

{
  return __WEBPACK_IMPORTED_MODULE_2__store__["a" /* default */].getters;
}
Run Code Online (Sandbox Code Playgroud)

没有实际的商店对象

ecmascript-6 vue.js vue-component vuex vuejs2

15
推荐指数
1
解决办法
9625
查看次数

使用IdentityServer4和自定义配置DBContext

我创建了一个定制IConfigurationDbContext的以便将IDS4与Oracle一起使用。

  public class IdentityConfigurationDbContext :  DbContext, IConfigurationDbContext {
        private readonly ConfigurationStoreOptions storeOptions;

        public IdentityConfigurationDbContext(DbContextOptions<IdentityServerDbContext> options)
         : base(options) {
    }

    public IdentityConfigurationDbContext(DbContextOptions<ConfigurationDbContext> options, ConfigurationStoreOptions storeOptions)
        : base(options) {
        this.storeOptions = storeOptions ?? throw new ArgumentNullException(nameof(storeOptions));
    }

    public DbSet<Client> Clients { get; set; }
    public DbSet<IdentityResource> IdentityResources { get; set; }
    public DbSet<ApiResource> ApiResources { get; set; }

    protected override void OnModelCreating(ModelBuilder modelBuilder) {
        modelBuilder.ConfigureClientContext(storeOptions);
        modelBuilder.ConfigureResourcesContext(storeOptions);

        base.OnModelCreating(modelBuilder);
    }
  }
Run Code Online (Sandbox Code Playgroud)

在ConfigureService中:

 services.AddIdentityServer()
                .AddTemporarySigningCredential()
                .AddAspNetIdentity<ApplicationUser>();
Run Code Online (Sandbox Code Playgroud)

我也有这样的习惯IClientStore,它被添加到容器中:

services.AddScoped<IClientStore, ClientStore>();
Run Code Online (Sandbox Code Playgroud)

运行IdentityConfigurationDbContext …

c# entity-framework asp.net-identity asp.net-core identityserver4

9
推荐指数
2
解决办法
3950
查看次数

从非 vue 文件访问 vue 3 应用程序实例 api

在 vue 2 中,您可以从 .js 文件访问 Vue 实例全局 api,如下所示:

Vue.prototype.$auth
Run Code Online (Sandbox Code Playgroud)

在 Vue 3 中,你有应用程序实例,据我所知,它现在只存在于 main.js 中

例如,如果我有 helper.js,我如何app.config.globalProperties.$auth从帮助文件中访问?

vue.js vuejs3 vue-composition-api

8
推荐指数
1
解决办法
6290
查看次数

单击android更改TextView背景颜色

我正在尝试在单击时更改textview的背景.

例如,如果单击文本视图,则背景将变为黄色并保持黄色,直到再次单击为止.然后它返回到默认背景.

当前textview按下时的背景更改,但在发布时返回默认值.

我在互联网上搜索解决方案,并查看堆栈溢出的大部分解决方案,仍然没有解决方案.

可绘制/ selector.xml:

<selector xmlns:android="http://schemas.android.com/apk/res/android">
     <item android:drawable="@drawable/circle_on" android:state_enabled="true" android:state_pressed="true"/>
     <item android:drawable="@drawable/circle_on" android:state_enabled="true" android:state_focused="true"/>
     <item android:drawable="@drawable/circle_off"/>
</selector>
Run Code Online (Sandbox Code Playgroud)

可绘制/ circle_on:

<shape xmlns:android="http://schemas.android.com/apk/res/android"
   android:shape="oval" >
   <stroke
     android:width="2dp"
     android:color="@color/Gray" >
   </stroke>
   <solid android:color="@color/LightBlue" />
</shape>
Run Code Online (Sandbox Code Playgroud)

可绘制/ circle_off:

<shape xmlns:android="http://schemas.android.com/apk/res/android"
   android:shape="oval" >
    <stroke
        android:width="2dp"
        android:color="@color/Gray" >
    </stroke>
    <solid android:color="@color/WhiteSmoke" />
</shape>
Run Code Online (Sandbox Code Playgroud)

TextView的:

  <TextView
                style="@style/RoundText"
                android:layout_width="50dp"
                android:layout_height="50dp"
                android:background="@drawable/repeat_selector"
                android:clickable="true"
                android:text="Sun" >
            </TextView>
Run Code Online (Sandbox Code Playgroud)

文字样式:

  <style name="RoundText">
    <item name="android:textColor">#555555</item>
    <item name="android:gravity">center_vertical|center_horizontal</item>
    <item name="android:textSize">15sp</item>
    <item name="android:textStyle">bold</item>
    <item name="android:fontFamily">sans-serif-thin</item>
</style>
Run Code Online (Sandbox Code Playgroud)

有人可以告诉我我做错了什么

谢谢.

MY解决方案:

    public class PlanTextView extends …
Run Code Online (Sandbox Code Playgroud)

android textview android-background

7
推荐指数
2
解决办法
3万
查看次数

更改所有字符串属性最大长度

在EF 6中,我可以这样做:

modelBuilder
  .Properties()
  .Where(p => p.PropertyType == typeof(string) && 
              p.GetCustomAttributes(typeof(MaxLengthAttribute), false).Length == 0)
  .Configure(p => p.HasMaxLength(2000));
Run Code Online (Sandbox Code Playgroud)

由于EF7 ModelBuilder没有这个Properties()功能,我如何在EF7中做同样的事情?

c# entity-framework entity-framework-core

7
推荐指数
1
解决办法
752
查看次数

vuejs挂载生命周期不触发

在我的App组件下面,mount()生命周期钩子没有被触发:

<template>
  <div>
    <div v-if='signedIn'>
        <router-view />
    </div>
  </div>
</template>

<script>
import Vue from 'vue'
import Oidc from 'oidc-client'

Vue.use(Oidc)

export default {
  data () {
    return {
      user: null,
      signedIn: false,
      mgr: new Oidc.UserManager({...settings...})
    }
  },
  methods: {
    signIn () {
    },
    signOut () {
    },
    getUser () {
    },
    mounted () {
      this.getUser()
    }
  }
}
</script>
Run Code Online (Sandbox Code Playgroud)

我已经多次查看代码,不知道我缺少什么.我在main.js文件中有这个:

new Vue({
  el: '#app',
  render: h => h(App),
  router
})
Run Code Online (Sandbox Code Playgroud)

vue.js vue-component vuejs2

7
推荐指数
1
解决办法
8617
查看次数

在 vitejs 和 vuejs 中使用环境变量

我正在尝试在 Vue 3 应用程序中运行时访问环境变量。我使用 vitejs 进行捆绑。

应用程序部署在 AKS 上,值存储为 Kubernetes 密钥。

我按照此处此处的说明进行操作

我有一个 .env 文件,其中包含我想要公开的环境变量:

VITE_OKTA_CLIENT=$VITE_OKTA_CLIENT
VITE_OKTA_ISSUER=$VITE_OKTA_ISSUER
Run Code Online (Sandbox Code Playgroud)

$VITE_OKTA_ISSUER是我的 k8s pod 中的 env 变量及其实际值。

我尝试使用这样的变量:

import.meta.env.VITE_OKTA_CLIENT
import.meta.env.VITE_OKTA_ISSUER
Run Code Online (Sandbox Code Playgroud)

导入的值未定义

这就是我的 vitejs 配置:

import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import vueI18n from '@intlify/vite-plugin-vue-i18n'
const path = require('path')

// https://vitejs.dev/config/
export default defineConfig({
  resolve: {
    alias: {
      '@': path.resolve(__dirname, '/src'),
      '@okta/okta-auth-js': '@okta/okta-auth-js/dist/okta-auth-js.umd.js'
    }
  },
  optimizeDeps: {
    include: [
      '@vue/apollo-composable'
    ]
  },
  plugins: [
    vue(),
    vueI18n({
      include: …
Run Code Online (Sandbox Code Playgroud)

vue.js kubernetes vuejs3 vite

6
推荐指数
0
解决办法
6795
查看次数

Itextsharp:如何在页面中间放置文本

我正在使用下面的代码创建一个标题页面.

public static byte[] CreatePageHeader(List<string> texts) {
        var stream = new MemoryStream();
        Document doc = null;

        try {
            doc = new Document();
            PdfWriter.GetInstance(doc, stream);
            doc.SetMargins(50, 50, 50, 50);
            doc.SetPageSize(new iTextSharp.text.Rectangle(iTextSharp.text.PageSize.LETTER.Width, iTextSharp.text.PageSize.LETTER.Height));
            Font font = new Font(Font.FontFamily.HELVETICA, 10f, Font.NORMAL);
            doc.Open();

            Paragraph para = null;
            foreach (string text in texts) {
                para = new Paragraph(text, font);
                doc.Add(para);
            }

        } catch (Exception ex) {
            throw ex;
        } finally {
            doc.Close();
        }

        return stream.ToArray();
    }
Run Code Online (Sandbox Code Playgroud)

这工作正常,但它显示页面顶部的文本.但我希望它在页面中间.

请问如何修改此代码呢?

c# itextsharp

4
推荐指数
1
解决办法
1万
查看次数

覆盖 vuetify 按钮文本颜色

如何覆盖工具栏中按钮文本的默认活动颜色:

v-btn(:to="item.path" active-class="v-btn--active toolbar-btn-active") {{item.meta.title}}
Run Code Online (Sandbox Code Playgroud)

我创建了这个类来尝试覆盖它:

.toolbar-btn-active {
  background-color: white;
  &::before {
    background-color: white;
  }
  .v-btn__content {
    color: red !important;
   }
}
Run Code Online (Sandbox Code Playgroud)

只有背景有效。如何修改我的 css 以更新按钮颜色?

这是呈现的 html:

<a href="/document" class="v-btn v-btn--active toolbar-btn-active">
           <div class="v-btn__content">Document</div>
</a>
Run Code Online (Sandbox Code Playgroud)

html css vue.js vuetify.js

4
推荐指数
1
解决办法
6305
查看次数