deep-learning - TypeError:预期大小为浮点数,得到
问题描述
我正在尝试运行代码来生成字体模型,如下所示:
import pygame
from pygame import freetype
from text_utils import FontState
import numpy as np
import matplotlib.pyplot as plt
import _pickle as cp
pygame.init()
ys = np.arange(8, 200)
A = np.c_[ys, np.ones_like(ys)]
xs = []
models = {} # linear model
FS = FontState()
# plt.figure()
# plt.hold(True)
for i in range(len(FS.fonts)):
font = freetype.Font(FS.fonts[i], size=12)
h = []
for y in ys:
h.append(font.get_sized_glyph_height(y))
h = np.array(h)
m, _, _, _ = np.linalg.lstsq(A, h)
models[font.name] = m
print("{}:\t{}".format(i, font.name))
xs.append(h)
with open('font_px2pt.cp', 'w') as f:
cp.dump(models, f)
# plt.plot(xs,ys[i])
当我跑步时,我得到了错误:
请帮我!
解决方案
作为第一次尝试,您可能会y
尝试float
使用float(y)
.
推荐阅读
- php - 在 android studio 中使用 ion 库上传图片
- vue.js - 如何在Vue中获取元素调用函数(无事件)
- php - SQL 语法错误。无法从表中拉出并插入到另一个表
- javascript - 在 React Native 中使用 Magento2 API
- c# - 保存 XML 文件而不进行格式化
- javascript - 如何在 componentDidMount 中模拟类函数
- opentok - 添加到发布者的下一个方法 changeVideoTrack/changeAudioTrack
- amazon-cloudformation - 无服务器部署问题
- c++ - 根据时间和日期查找插入数据的冲突
- hibernate - Grails:会话和事务无法正常工作(单次刷新后失败或分离)