我尝试使用validation_data方法,但有问题
model.fit([X['macd_train'], X['rsi_train'],X['ema_train']],
Y['train'],
sample_weight=sample_weight,
validation_data=([X['macd_valid'],
X['rsi_valid'],
X['ema_valid']],
Y['valid']),
epochs=nb_epochs,
batch_size=512,
verbose=True,
callbacks=callbacks)
Run Code Online (Sandbox Code Playgroud)
我收到一个错误:
ValueError: The model expects 3 arrays, but only received one array. Found: array with shape (127, 100, 8)
Run Code Online (Sandbox Code Playgroud)
如果我使用,我的代码可以正常运行 validation_data=None
这是我的变量信息
X['macd_train'].shape, X['macd_valid'].shape
(507, 100, 2), (127, 100, 2)
X['rsi_train'].shape, X['rsi_valid'].shape
(507, 100, 1), (127, 100, 1)
X['ema_train'].shape, X['ema_valid'].shape
(507, 100, 6), (127, 100, 6)
Y['train'].shape, Y['valid'].shape
(507, 1), (127, 1)
Run Code Online (Sandbox Code Playgroud) 我尝试将一堆数据插入数据库
insert_list = [(1,1,1,1,1,1),(2,2,2,2,2,2),(3,3,3,3,3,3),....] #up to 10000 tuples in this list
conn = pyodbc.connect('DRIVER={FreeTDS};SERVER=xxxxx;DATABASE=xxxx;UID=xx;PWD=xx;TDS_Version=7.0')
cursor = conn.cursor()
sql = "insert into ScanEMAxEMAHistoryDay(SecurityNumber, EMA1, EMA2, CrossType, DayCross, IsLocalMinMax) values (?, ?, ?, ?, ?, ?)"
cursor.executemany(sql, insert_list)
Run Code Online (Sandbox Code Playgroud)
cursor.executemany(sql,insert_list)
pyodbc.ProgrammingError:('参数类型无效.param-index = 4 param-type = numpy.int64','HY105')
减少到100元组:
cursor.executemany(sql, insert_list[:100])
Run Code Online (Sandbox Code Playgroud)
cursor.executemany(sql,insert_list [:100])
pyodbc.ProgrammingError:('参数类型无效.param-index = 4 param-type = numpy.int64','HY105')cursor.executemany(sql,insert_list [:100])
减少到5元组:
cursor.executemany(sql, insert_list[:5])
conn.commit()
Run Code Online (Sandbox Code Playgroud)
这可以插入数据库
我试着:
sql = 'SET GLOBAL max_allowed_packet=50*1024*1024'
cursor.execute(sql)
Run Code Online (Sandbox Code Playgroud)
在excutemany()之前,它有一个错误:
pyodbc.ProgrammingError:('42000',"[42000] [FreeTDS] [SQL Server]'GLOBAL'不是公认的SET选项.(195)(SQLExecDirectW)")
我是怎么解决这个问题的
谢谢.
我有一个从 pylab_examples 示例代码创建 OHLC 图表的代码:来自http://matplotlib.org/examples/pylab_examples/finance_demo.html的 Finance_demo.py :
图表输出
然后我尝试在迄今为止的 20 处绘制一条水平线,但出现空图错误。
这是代码:
#!/usr/bin/env python
import matplotlib.pyplot as plt
from matplotlib.dates import DateFormatter, WeekdayLocator,\
DayLocator, MONDAY
from matplotlib.finance import quotes_historical_yahoo_ohlc, candlestick_ohlc
# (Year, month, day) tuples suffice as args for quotes_historical_yahoo
date1 = (2004, 2, 1)
date2 = (2004, 4, 12)
mondays = WeekdayLocator(MONDAY) # major ticks on the mondays
alldays = DayLocator() # minor ticks on the days
weekFormatter = DateFormatter('%b %d') # e.g., Jan 12
dayFormatter = …Run Code Online (Sandbox Code Playgroud) 我正在尝试将所有内容作为图像保存到另一个页面中。
我已经探索了执行此操作的方法,因此我认为我需要首先将该页面转换为画布。
因此,我尝试使用要先将其保存为 iframe 的链接,然后将 iframe 转换为画布,但它不起作用。
$(document).ready(function(){
var element = $("#html-content-holder"); // global variable
var getCanvas; // global variable
$("#btn-Preview-Image").on('click', function () {
html2canvas(element, {
onrendered: function (canvas) {
$("#previewImage").append(canvas);
getCanvas = canvas;
}
});
});
$("#btn-Convert-Html2Image").on('click', function () {
var imgageData = getCanvas.toDataURL("image/png");
// Now browser starts downloading it instead of just showing it
var newData = imgageData.replace(/^data:image\/png/, "data:application/octet-stream");
$("#btn-Convert-Html2Image").attr("download", "your_pic_name.png").attr("href", newData);
});
});Run Code Online (Sandbox Code Playgroud)
<script src="http://files.codepedia.info/uploads/iScripts/html2canvas.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<iframe id="html-content-holder" width="100%" height="100%" src="http://api.marketanyware.com/chartv2/engine/index.html?{bodyColor:%27#000000',api:{params:[{Stock:'SET',Period:'2hour',ChartList:{OHLC:true,EODHLine:true,EMA: [5, 10, 25, 50, 75, …Run Code Online (Sandbox Code Playgroud)python ×3
canvas ×1
freetds ×1
html ×1
html2canvas ×1
iframe ×1
keras ×1
matplotlib ×1
numpy ×1
pyodbc ×1
sql-server ×1