如何解决Scipy最小化名称'init_weigths'未定义
任何人都知道为什么我在最小化函数中收到此未定义的错误吗? 在调用最小化函数之前定义并填充的float数组中的init_weights变量。但是它似乎没有读
class Category extends Model
{
use SoftDeletes;
protected $guarded = ['id'];
protected $hidden = ['id','category_id'];
public function parentCategory()
{
return $this->belongsTo( Category::class,'category_id','id' );
}
public function categories()
{
return $this->hasMany(Category::class);
}
public function roles()
{
return $this->belongsToMany(Role::class);
}
public function posts()
{
return $this->belongsToMany(Post::class);
}
public function users()
{
return $this->belongsToMany(User::class);
}
public function childrenCategories()
{
return $this->hasMany(Category::class)->with('categories');
}
}
class Role extends Model
{
protected $guarded = ['id'];
public function users()
{
return $this->belongsToMany(User::class);
}
public function permission()
{
return $this->belongsToMany(Permission::class);
}
public function hasPermission($permission)
{
return !!$permission->intersect($this->roles->permission)->count();
}
}
class User extends Authenticatable
{
use Notifiable,SoftDeletes,UsersOnlineTrait;
protected $guarded = [
'id',];
protected $hidden = [
'password','remember_token',];
protected $casts = [
'email_verified_at' => 'datetime','avatar_path' => 'array','experiences' => 'array',];
public function group()
{
return $this->belongsToMany(UserGroup::class,'user_user_group');
}
public function child()
{
return $this->hasMany(User::class)->with('child');
}
public function parent()
{
return $this->belongsTo(User::class,'user_id');
}
public function properties()
{
return $this->hasOne(UsersProperty::class);
}
public function roles()
{
return $this->belongsToMany(Role::class);
}
public function hasRole($role)
{
return $this->roles->contains('id',$role);
/*if (is_string($role)) {
} else {
return !!$role->intersect($this->roles)->count();
}*/
}
public function hasRoleByName($role)
{
if ($role == null) return false;
if (is_string($role)) {
return $this->roles->contains('name',$role) || $this->roles->contains('label',$role);
} else {
return !!$role->intersect($this->roles)->count();
}
}
public function categories()
{
return $this->belongsToMany(Category::class);
}
}
解决方法
eweights = np.array(init_weights)
我必须先将常规数组转换为numpy数组,然后再将其传递到最小化
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。