Constructing function from lists within lists in Python
By : Thirumalai
Date : March 29 2020, 07:55 AM
With these it helps This sounds like recursion and iteration might be useful. Does this do what you want? code :
def flatten(data):
res = []
if hasattr(data, '__iter__'):
for el in data:
res.extend(flatten(el))
else:
res.append(data)
return res
reduce(getattr, flatten(x), res)
|
Constructing C# Lists from that what is enumerable
By : Mh Emon
Date : March 29 2020, 07:55 AM
like below fixes the issue If t2 should be an array of 2D arrays (list assignment suggests so) then the declaration of t2 is wrong. If think you are after: code :
var t = new List<int[,]>();
var t2 = new int[10][,];
for (int i = 0; i < t2.Length; ++i)
{
t2[i] = new int[4, 4];
}
var r = new List<int[,]>(t);
var r2 = new List<int[,]>(t2); // no error!
|
Rust + Rust Image - Private 'Associated Type'?
By : Allen
Date : March 29 2020, 07:55 AM
it helps some times Chris Morgan is spot on - when you are accepting a GenericImage, you have to handle a generic Pixel. However, you are trying to use a specific one - Rgba. Even more than that, you have to specify the type of the channels of the Rgba. A notable issue with your original code is: what do you do when the GenericImage is composed of pixels that don't support transparency? code :
fn remove_background<T>(img: &mut T)
where T: image::GenericImage<Pixel=image::Rgba<u8>>
{
let background_color = img.get_pixel(0, 0).to_rgba();
if background_color[3].to_uint().unwrap() > 0 {
for (_, _, color) in img.pixels_mut() {
let rgba = color.to_rgba();
let (dr,dg,db) = (rgba[0] - background_color[0],
rgba[1] - background_color[1],
rgba[2] - background_color[2]);
// Remove the background colour.
if (dr*dr + dg*dg + db*db).to_uint().unwrap() < 16384 {
for c in color.channels_mut().iter_mut() { *c = 0 }
}
}
}
}
|
Constructing dynamic lists of lists with Polymer
By : Vasily Petrushin
Date : March 29 2020, 07:55 AM
I wish this helpful for you I eventually got this working. As a starting point, I leaned heavily on the example given in the docs that uses the app-drawer-template. As suggested by a commenter above, using a router ended up being part of the answer. What was confusing me was that I wan't sure how to dynamically update both the used in that example as well as the . I wanted both to represent the same list of users. How would I keep these in sync, etc? code :
<dom-module id="user-provider">
<template>
<style>
:host {
display: block;
box-sizing: border-box;
</style>
<paper-fab icon="refresh" on-tap="refresh"></paper-fab>
</template>
<script>
Polymer({
is: 'user-provider',
properties: {
users: {
type: Array,
notify: true,
reflectToAttribute: true
}
},
refresh: function() {
this.refreshUsers();
},
refreshUsers: function() {
var _this = this;
// in reality I require a browserify module here
window.getUsersViaPromise()
.then(retrievedUsers => {
_this.users = retrievedUsers;
});
},
// Element Lifecycle
ready: function() {
this.users = [];
this.refreshUsers();
}
});
</script>
</dom-module>
<dom-module id="user-selector">
<template>
<style>
:host {
display: block;
--app-primary-color: #4285f4;
--app-secondary-color: black;
}
</style>
<iron-selector
selected="{{incoming}}"
attr-for-selected="name"
class="drawer-list"
role="navigation">
<template is="dom-repeat" items="{{users}}">
<a name="view{{index}}">{{item.instanceName}}</a>
</template>
<a name="settings">Settings</a>
</iron-selector>
</template>
<script>
Polymer({
is: 'user-selector',
properties: {
incoming: {
type: String,
reflectToAttribute: true,
notify: true
},
users: {
type: Array,
reflectToAttribute: true
},
}
});
</script>
</dom-module>
<dom-module id="user-pages">
<template>
<style>
:host {
display: block;
box-sizing: border-box;
}
</style>
<iron-pages role="main" selected="{{incoming}}" attr-for-selected="name">
<template is="dom-repeat" items="{{users}}">
<user-summary
name="view{{index}}"
username="{{item.userName}}">
</user-summary>
</template>
<settings-view name="settings"></settings-view>
</iron-pages>
</template>
<script>
Polymer({
is: 'user-pages',
properties: {
users: Array,
incoming: {
type: String,
reflectToAttribute: true,
notify: true
},
}
});
</script>
</dom-module>
<dom-module id="my-app">
<template>
<style>
:host {
display: block;
--app-primary-color: #4285f4;
--app-secondary-color: black;
}
app-header {
background-color: var(--app-primary-color);
color: #fff;
}
app-header paper-icon-button {
--paper-icon-button-ink-color: white;
}
.drawer-list {
margin: 0 20px;
}
.drawer-list a {
display: block;
padding: 0 16px;
line-height: 40px;
text-decoration: none;
color: var(--app-secondary-color);
}
.drawer-list a.iron-selected {
color: black;
font-weight: bold;
}
.drawer-list a.subroute {
padding-left: 32px;
}
</style>
<app-route
route="{{page}}"
data="{{routeData}}"
tail="{{subroute}}"></app-route>
<app-drawer-layout fullbleed>
<!-- Drawer content -->
<app-drawer>
<app-toolbar>My App</app-toolbar>
<start-app-button></start-app-button>
<user-provider users="{{retrievedUsers}}"></user-provider>
<user-selector incoming="{{page}}" users="{{retrievedUsers}}">
</user-selector>
</app-drawer>
<!-- Main content -->
<app-header-layout has-scrolling-region>
<app-header condenses reveals effects="waterfall">
<app-toolbar>
<paper-icon-button icon="menu" drawer-toggle></paper-icon-button>
<div title>My App</div>
</app-toolbar>
</app-header>
<user-pages
incoming="{{page}}"
users="{{retrievedUsers}}">
</user-pages>
</app-header-layout>
</app-drawer-layout>
</template>
<script>
Polymer({
is: 'my-app',
properties: {
page: {
type: String,
reflectToAttribute: true
},
},
observers: [
'_routePageChanged(routeData.page)'
],
_routePageChanged: function(page) {
this.page = page || 'view1';
}
});
</script>
</dom-module>
|
feature Union of hetereogenous features
By : Marcos Freire Junior
Date : March 29 2020, 07:55 AM
Hope that helps Assuming that you want to deal with set of features in independent models and then ensemble their results together, I'll write an answer below. However, if you want to simply use features from all 3 feature extraction techniques in a single model then just append them together into a single dataset and use it for training. I think the easiest way to do this within a Pipeline is to create a single (978*965) pandas DataFrame that includes features from all three techniques. Then within your pipeline you can define a custom class that selects groups of features, for example this should work:
|