动态密钥的调用方法

时间:2019-01-14 10:00:15

标签: javascript vue.js quasar

这是我的数据对象:

registration: {
        step1: {
          project: '',
        },
        step2: {
          adres: '',
          facade: '',
          floor: '',
        },
      },

我正在尝试通过每个步骤的单个功能来验证用户输入:

validateStep(stepNumber) { 
    const self = this; 
    const step = step${stepNumber}; 
    console.log(step); 
    this.$v.registration[${step}].touch(); 
    if (this.$v.registration[${step}].$error) { 
      this.$q.notify('Controleer aub de velden opnieuw'); 
      return; 
    } 

    self.$refs.stepper.next();
}

但这会出现此错误:

  

TypeError:this。$ v.registration [“”。concat(...)]。touch不是   功能

我也这样尝试过:

validateStep(stepNumber) {
      const self = this;
      const step = `step${stepNumber}`;
      console.log(this.$v.registration[step]); //this prints the correct object
      const currentStep = this.$v.registration[step];
      currentStep.touch();

      if (currentStep.$error) {
        this.$q.notify('Controleer aub de velden opnieuw');
        return;
      }
      self.$refs.stepper.next();
    },

我在做什么错了?

1 个答案:

答案 0 :(得分:1)

Vuelidate方法应为import numpy as np import tensorflow as tf #%% # Number of data pionts nx and dimension dx nx = 10 dx = 4 # Input data x = np.random.rand(nx,dx) #%% Numpy # Transform to logits for binary classification with sigmoid matrix = np.random.rand(dx,1) logits = np.matmul(x,matrix) print('Logits dimensions: %s' % str(logits.shape)) # Sigmoid def sigmoid(x): return 1. / (1. + np.exp(-x)) sig = sigmoid(logits) print('Sigmoid dimensions: %s' % str(sig.shape)) # Discrete probabilities p = np.random.randint(2,size=nx)[:,np.newaxis] print('Probability dimensions: %s'% str(p.shape)) # Cross entropy for each data point ce = p*np.log(1/sig)+(1-p)*np.log(1/(1-sig)) # Mean cross entropy mce = np.mean(ce) print('MCE with np: %.16f' % mce) #%% Tensorflow xp = tf.placeholder(dtype=tf.float64,shape=[None,dx]) pp = tf.placeholder(dtype=tf.float64,shape=[None,1]) model = xp c1 = tf.constant(matrix,dtype=tf.float64) model = tf.matmul(xp,c1) sigtf = tf.nn.sigmoid(model) cetf = tf.nn.sigmoid_cross_entropy_with_logits(labels=pp,logits=model) mcetf = tf.losses.sigmoid_cross_entropy(pp,model) mcetf2 = tf.reduce_mean(cetf) sess = tf.Session() feed = {xp:x,pp:p} print('Error in logits: %.16f' % np.max(np.abs(sess.run(model,feed)-logits))) print('Error in sigmoid: %.16f' % np.max(np.abs(sess.run(sigtf,feed)-sig))) print('Error in CE: %.16f' % np.max(np.abs(sess.run(cetf,feed)-ce))) print('Error in MCE: %.16f' % np.abs(sess.run(mcetf,feed)-mce)) print('Error in MCE2: %.16f' % np.abs(sess.run(mcetf2,feed)-mce)) sess.close() ,而不是$touch