相关动态
Python基于RNN循环神经网络的音乐生成AI项目源码+模型文件(高分项目)
2024-12-29 21:42
import tensorflow as tf import numpy as np import pandas as pd import hyperpara as hp from model import MyModel from midi_utils import midi_to_notes, notes_to_midi def predict_next_note( notes: np.ndarray, keras_model: MyModel, temperature: float = 1.0): """Generates a note IDs using a trained sequence model.""" # Add batch dimension inputs = tf.expand_dims(notes, 0) predictions = model.predict(inputs) pitch_logits = predictions['pitch'] step = predictions['step'] duration = predictions['duration'] pitch_logits /= temperature pitch = tf.random.categorical(pitch_logits, num_samples=1) pitch = tf.squeeze(pitch, axis=-1) duration = tf.squeeze(duration, axis=-1) step = tf.squeeze(step, axis=-1) step = tf.maximum(0, step) duration = tf.maximum(0, duration) return int(pitch), float(step), float(duration) def generate(sample_midi_file: str, output_midi_file: str, model, num_predictions): raw_notes = midi_to_notes(sample_midi_file)

Python基于RNN循环神经网络的音乐生成AI项目源码+模型文件(高分项目)

sample_notes = np.stack([raw_notes[key] for key in hp.key_order], axis=1) input_notes = ( sample_notes[:hp.seq_length] / np.array([hp.vocab_size, 1, 1])) generated_notes = [] prev_start = 0 for _ in range(num_predictions): pitch, step, duration = predict_next_note( input_notes, model, hp.temperature) start = prev_start + step end = start + duration input_note = (pitch, step, duration) generated_notes.append((*input_note, start, end)) input_notes = np.delete(input_notes, 0, axis=0) input_notes = np.append( input_notes, np.expand_dims(input_note, 0), axis=0) prev_start = start generated_notes = pd.Dataframe( generated_notes, columns=(*hp.key_order, 'start', 'end')) print(generated_notes.head(10)) out_pm = notes_to_midi( generated_notes, out_file=output_midi_file, instrument_name="Acoustic Grand Piano") if __name__ == '__main__': model = MyModel() model.load_weights("training_checkpoints\ckpt_50")
    以上就是本篇文章【Python基于RNN循环神经网络的音乐生成AI项目源码+模型文件(高分项目)】的全部内容了,欢迎阅览 ! 文章地址:http://ww.kub2b.com/news/15112.html
     栏目首页      相关文章      动态      同类文章      热门文章      网站地图      返回首页 企库往资讯移动站 http://ww.kub2b.com/mobile/ , 查看更多   
最新文章
以“心”聚力,共铸电影辉煌
1905电影网专稿 4月10日至13日,电影频道节目中心在全国宣传干部学院(八大处校区)成功主办全国电影宣传骨干人才培训班(第一期
人人都需要一场1v4的恋爱
作者|谢明宏编辑|李春晖让人看得津津有味又醒世育人的爱情剧以几个“对手”为宜?这大概也和现实生活差不多,一个人千挑万选,两
一辆自动驾驶车需要几根天线?手机供应商「一辆自动驾驶车需要几根天线?」
未来,一辆车子究竟需要使用多少天线,才能具备自动驾驶的能力? 这可不是在开玩笑的!根据爱尔兰天线技术供应商——锐锋(Taogla
Use of Cookies and Other Tracking Technologies黑莓手机官网「Use of Cookies and Other Tracking Technologies」
Last Updated: January 1, 2023This notice describes the types of Cookies and Other Tracking Technologies (“Cookies”) th
nfc安卓手机怎么设置手机nfc功能在哪里「nfc安卓手机怎么设置」
NFC在安卓手机上的设置指南随着科技的不断进步,NFC(近场通讯)技术已经越来越普及。许多安卓手机都配备了NFC功能,它不仅能够
关税加码,普通投资者如何应对?
4月7日,股市经历剧烈波动,上证指数单日下跌7.34%,交易资金触及止损后恐慌性出逃,但更值得关注的是股指期货端出现历史极端行
2025年北京市全民健身“社区杯”骑行系列活动第四站举办
4月15日,2025年北京市全民健身社区杯骑行系列活动暨京彩骑行第四站在北京经济技术开发区亦庄新城滨河森林公园举行。本次活动以
小米一键上锁神器轻松加密,安全守护您的隐私加密手机「小米一键上锁神器轻松加密,安全守护您的隐私」
在互联网时代,信息安全已经成为每个人都需要关注的问题。尤其是在智能手机普及的今天,我们的个人信息、聊天记录、支付密码等隐
午盘:美股涨幅扩大 道指涨逾300点美股手机新浪网「午盘:美股涨幅扩大 道指涨逾300点」
  北京时间6日凌晨,美股周二午盘涨幅扩大,道指上涨逾300点,纳指上涨1.3%。市场密切关注美国总统大选选情,以及本周的财报与
Isomorphic Labs获6亿美元,加速 AI 药物研发
金融时报消息,总部位于英国伦敦的 Isomorphic Labs 宣布完成6 亿美元融资。本次由 Thrive Capital 领投,现有投资者谷歌的