# -*- coding: utf-8 -*- """ 本程序装tensorflow 版本1.1.0, python版本 3.6.0下测试成功. """ from __future__ import print_function import numpy as np import tensorflow as tf from six.moves import range import collections import random import csv from matplotlib import pyplot as plt class BatchGenerator: def __init__(self, window_size, window_range): self.cursor = 0. self.window = window_size self.range = window_range def next(self): x = np.zeros([self.window, 1]) y = np.zeros([self.window, 1]) d = np.arange(self.cursor, self.cursor + 1., 1. / self.window) for i in range(self.window): l = np.sin(d[i]) x[i, 0] = d[i] y[i, 0] = l self.cursor += 1. / self.window return y[:self.window - 1], y[1:], x[:self.window - 1] num_nodes = 64 window_size = 5 window_range
tensorflow 下 用lstm预测sin
最新推荐文章于 2025-06-30 09:05:31 发布