作家
登录

如何用 TensorFlow 教机器人作曲?秘诀原来是这样

作者: 来源: 2017-05-09 17:04:45 阅读 我要评论

 at a time 
  •  
  • n_visible = 2*note_range*num_timesteps #This is the size of the visible layer. 
  •  
  • n_hiDDen = 50 #This is the size of the hidden layer 
  • 练习次数,批量处理的大年夜小,还有进修率。

    1. num_epochs = 200 #The number of training epochs that we are going to run. For each epoch we go through the entire data set
    2.  
    3. BAtch_size = 100 #The number of training examples that we are going to send through the RBM at a time
    4.  
    5. lr = tf.constant(0.005, tf.float32) #The learning rate of our model 

    x 是投入收集的数据

    w 用来存储权重矩阵,或者叫做两层之间的关系

    此外还须要两种 bias,一个是隐蔽层的 bh,一个是可见层的 bv

    1. x = tf.placeholder(tf.float32, [None, n_visible], name="x") #The placeholder variable that holds our data 
    2.  
    3. W = tf.Variable(tf.random_normal([n_visible, n_hidden], 0.01), name="W") #The weightMATrix that stores the edge weights 
    4.  
    5. bh = tf.Variable(tf.zeros([1, n_hidden], tf.float32, name="bh")) #The bias vector for the hidden layer 
    6.  
    7. bv = tf.Variable(tf.zeros([1, n_visible], tf.float32, name="bv")) #The bias vector for the visible layer 

    接着,用帮助办法 gibbs_sample 大年夜输入数据 x 中建立样本,以及隐蔽层的样本:

    gibbs_sample 是一种可以大年夜多重概率分布中提取样本的算法。

    它可以生成一个统计模型,个中,每一个状况都依附于前一个状况,并且随机地生成相符分布的样本。

    1. #The sample of x 
    2.  
    3. x_sample = gibbs_sample(1) 
    4.  
    5. #The sample of the hidden nodes, starting from the visible state of x 
    6.  
    7. h = sample(tf.sigmoid(tf.matMUl(x, W) + bh)) 
    8.  
    9. #The sample of the hidden nodes, starting from the visible state of x_sample 
    10.  
    11. h_sample = sample(tf.sigmoid(tf.matmul(x_sample, W) + bh)) 

        推荐阅读

        垃圾收集转运处理将信息化监管

      日前,四川省当局印发《四川省城乡垃圾处理举措措施扶植三年推动筹划》(以下简称《筹划》)。《筹划》提出,到2019岁尾,我省生活垃圾无害化处理才能将达7.05万吨/日,生活垃圾处理举措措施>>>详细阅读


      本文标题:如何用 TensorFlow 教机器人作曲?秘诀原来是这样

      地址:http://www.17bianji.com/lsqh/35102.html

    关键词: 探索发现

    乐购科技部分新闻及文章转载自互联网,供读者交流和学习,若有涉及作者版权等问题请及时与我们联系,以便更正、删除或按规定办理。感谢所有提供资讯的网站,欢迎各类媒体与乐购科技进行文章共享合作。

    网友点评
    自媒体专栏

    评论

    热度

    精彩导读
    栏目ID=71的表不存在(操作类型=0)