Why not using linear regression for finetuning the last layer of a neural network?

In transfer learning, often only the last layer of the network is retrained using gradient descent. However, the last layer of a common neural network performs only a linear transformation, so why do we use gradient descent and not linear (or logistic) regression to finetune the last layer?
Category: Data Science

The Events Calendar featured image as body background?

<?php if (has_post_thumbnail( $post->ID ) ): $thumb = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), 'full' ); elseif (tribe_event_featured_image( $event_id = get_the_ID())): $thumb = get_attachment_image_src(tribe_event_featured_image( $event_id), 'large' ); else: $thumb = array(get_template_directory_uri().'/images/background.jpg'); endif;?> <body <?php body_class(); ?> style="background-image: url('<?php echo $thumb['0'];?>') no-repeat fixed"> Hello Sir Experts, Please help, i am using "The Events Calendar" plugin, and i want to use event featured image as body backgound. Please check code! and it's demo event page: http://rankonone.com/dev/downtown/event/the-lion-king/
Category: Web

Using "Demon Adam" as optimizer in Tensorflow

I am working with a simple neural network in Google Colab using Python with Tensorflow where I've only tried to use the optimizers already available in keras such as Nadam, Adam, Adadelta, Adagrad etc. The best results so far were achieved with Adam. I found an interesting paper "Demon: Improved Neural Network Training with Momentum Decay" and I thought I'd try to use it and see if my results can get even better. The first line in the source code …
Category: Data Science

How to debug new shortcode? And how to get string from shortcode into code?

I am trying to write a simple plugin that fetches some data from an API endpoint. I am planning to read the api key from a shortcode, but didn't get that far yet. I wrote the following piece of code. The noob question I have is how do I even trigger the code so that I could debug it to see what happens ? If that's a simple question, the follow up would be how to read the api key …
Category: Web

need an explanation of the For Loop in the DBSCAN algorithm Demo

In the following code of the DBSCAN algorithm, as a beginner I need an explanation for what happens to the data in the bottom for loop and why ? Generate sample data import numpy as np from sklearn.cluster import DBSCAN from sklearn import metrics from sklearn.datasets import make_blobs from sklearn.preprocessing import StandardScaler centers = [[1, 1], [-1, -1], [1, -1]] X, labels_true = make_blobs(n_samples=750, centers=centers, cluster_std=0.4, random_state=0) X = StandardScaler().fit_transform(X) Compute DBSCAN db = DBSCAN(eps=0.3, min_samples=10).fit(X) core_samples_mask = np.zeros_like(db.labels_, dtype=bool) …
Category: Data Science

WP REST API V2 - Retrieve sub page by full slug (URL/Path)

I'm struggling to see if this is natively supported, or if it's not the best place to implement this functionality - in my app (Laravel) or the same side as the API (WordPress). Retrieving a single page (/about-us) via the slug is easy: /wp-json/wp/v2/pages?slug=about-us But the issue comes with retrieving a sub/child page. Consider /about-us/child-page - this works perfectly fine in WordPress but retrieving the page via the Rest API seems impossible? /wp-json/wp/v2/pages?slug=about-us/child-page /wp-json/wp/v2/pages?slug=%2Fabout-us%2Fchild-page%2F No Results. I can search for …
Category: Web

Getting text from custom field from customizer

So I've created a panel in the customizer section in WordPress to add the phone number to the site. It works fine in the back end but it wont show up in the front end here is my functions.php function home_smart_register_theme_customizer( $wp_customize ) { $wp_customize->add_panel( 'contact_info', array( 'priority' => 10, 'theme_supports' => '', 'title' => __( 'Contact Info', 'home_smart' ), 'description' => __( 'Set your current address.', 'home_smart' ), ) ); $wp_customize->add_section( 'contact_details_block' , array( 'title' => __('Phone Number','home_smart'), 'panel' …
Category: Web

flush_rewrite_rules() not working on plugin activation

I am experimenting with creating a simple plugin to create a custom post type named project but am having some trouble with the rewrite rules not been flushed on activation. I have the main plugin file with this function: register_activation_hook( __FILE__, 'Project_Custom_Post_Type::activate' ); Then within my class I have this: public function activate() { flush_rewrite_rules(); } My class has a construct of: public function __construct() { add_action( 'init', array( $this, 'register_post_type' ), 0 ); } I cannot see why it …
Category: Web

Issue logging in from second computer

I'm fairly new to Wordpress, so please bear with me on this. I've been having issues logging into my Wordpress admin panel on a second computer. I originally set up WP on my work computer and all works fine there. However, I tried to log in with my personal computer and was denied. After logging into WP successfully (blue side panel), I navigated to the WP Admin link at the bottom. When I click it, it takes me to a …
Category: Web

How to access an embedding table that is too large to fully load into memory?

I'm currently trying to find a way of loading/deserializing a .json file containing Flair word embeddings that is too large to fit in my RAM at once (>60GB .json with 32GB of RAM). My current code for loading the embedding is below. def get_embedding_table(config): words_id2vec = json.load(open(config.words_id2vector_filename, 'r')) words_vectors = [0] * len(words_id2vec) for id, vec in words_id2vec.items(): words_vectors[int(id)] = vec words_vectors.append(list(np.random.uniform(0, 1, config.embedding_dim))) words_embedding_table = tf.Variable(name='words_emb_table', initial_value=words_vectors, dtype=tf.float32) The rest of the code that I am trying to reproduce …
Category: Data Science

get_adjacent_post by language

I am using Polylang plugin, which assigns each post to a taxonomy 'language'. While using get_adjacent_post() I want to bring only those posts that belong to the language currently displayed. So I am writing the following: $prev_post = get_adjacent_post( true, '', true, 'language' ); $next_post = get_adjacent_post( true, '', false, 'language' ); But this brings the next and previous posts independently from the language they are currently in. Why? I understand in the documentation $in_same_term (first value) specifies whether post …
Category: Web

Create features for each row or only for a specific value

I have a problem. I want to predict when the customer will place another order in how many days if an order comes in. I have already created my target variable next_day_in_days. This specifies in how many days the customer will place an order again. And I would like to predict this. Since I have too few features, I want to do feature engineering. I would like to specify how many orders the customer has placed in the last 90 …
Category: Data Science

How to properly replace the_content with the html in a php file?

I've built a plugin that needs to overwrite the content on a specific page. It works, but it places all head content within the body, after my own html. Is there a way to fix that? add_filter('the_content', 'overwrite_content'); function overwrite_content($content) { if(is_page('Signup')){ require_once(plugin_dir_path(__FILE__).'/views/signup.php'); } else { return $content; } }
Category: Web

How to improve the result? Should I remove the columns?

I am using this dataset, the target column is the last one which is 'DEATH_EVENT', I have separated this last one. I am using KMeans to calculate the number of hits and misses. The result is quite bad, I think I should delete some columns or create a loop that deletes. What would you do? import numpy as np import matplotlib.pyplot as plt from sklearn.model_selection import train_test_split X = np.genfromtxt('heart_failure_clinical_records_dataset.csv', delimiter=',') X = np.delete(X, 0, 0) train, test = train_test_split(X, …
Category: Data Science

Preprocessing in TensorFlow

Good night, I am working on a paper comparing Python libraries for machine learning and deep learning. Trying to evaluate Keras and TensorFlow separately, I'm looking for information about TensorFlow methods or functions that can be used to preprocess datasets, such as those included in scikit-learn (sklearn.preprocessing) or the Keras preprocessing layers, but I can't find anything beyond a one hot enconding for labels... Does anyone know if what I am looking for exists? Thank you very much!
Category: Data Science

How to reset/remove added filters 'posts_join' and 'posts_orderby' after the loop is completed?

I am sorting results appear on the category archive page using these filters: posts_join and posts_orderby. There is a widget, which displays recent posts. I am using default recent posts widget of WordPress. But it's not showing any result. When I investigated I found that the applied filters are getting applied to this query. So, I tried remove the filters using the following code: remove_filter('posts_join', 'my_filter_join'); remove_filter('posts_orderby', 'my_filter_orderby'); But still it does not work. I also tried to put the …
Category: Web

Why my regression model always be dominanted by one feature?

I am working on a financial predict problem. which means it is a time series prediction problem. I have three features, which have high correlation(each two's corr is about 0.6) And I do the linear regression fit. I assume that the coefficient should be similiar among these three features, but i get a coefficient vector like this: [0.01, 0.15, 0.01] which means the second features have the biggest coff(features are normalized), and it can dominant the prediction result. I dont …
Category: Data Science

Set city as required if country is Singapore

I would like to set city checkout field as required if country is Singapore (if we only sell to Singapore, the city field is obligatorily optional). This is what I did so the user can only choose Singapore as the city, but there still is the "optional" label, which I want to become required. add_filter( 'woocommerce_checkout_fields', 'custom_checkout_fields', 10, 1 ); function custom_checkout_fields( $fields ) { $fields['billing']['billing_city']['type'] = 'select'; $fields['billing']['billing_city']['options'] = array('Singapore' => 'Singapore'); $fields['shipping']['shipping_city']['type'] = 'select'; $fields['shipping']['shipping_city']['options'] = array('Singapore' => …
Category: Web

Gutenberg selecting child blocks directly from appender

I created a block that uses inner blocks/child blocks. The parent block is named Columns and only child blocks named Column are allowed in it. The Column child block accepts any blocks. The structure looks like this: <Columnns> <Column><Any block></Column> <Column><Any block></Column> <Column><Any block> <Another block> <One more block></Column> </Columns> In the edit function for the child Column block, I am just using an inner blocks appender that allows any blocks to be added in it. The edit function for …
Category: Web

Correct Way to Move WordPress to Subdomain and Shop to Stay at root Domain

I have a WordPress website with WooCommerce configured. The root domain xyz.com is set to the shop but the blog is at xyz.com/blog. Now I want to move the blog to blog.xyz.com and keep the shop at the root domain. What would be a best way for this? Do I have to install additional WordPress in some other folder? Or is there is an easy way to do it with the current installation. Thanks.
Topic: dns Wordpress
Category: Web

Omit image captions from get_the_content()

I use a theme that calls get_the_content() to display short excerpts of the latest blog posts on the home page. Now I noticed that the excerpt sometimes starts with an image caption, if the blog post contains a picture at the very beginning. I usually do that and make the text float around it. I always set the first three caption fields on an image (Alt Text, Title, Caption). Is there any way to strip these image captions from the …
Category: Web

When to stop showing content on recommendation engines?

Let's take an example. I log into my Netflix account and see that it's suggesting the show Friends to me. But I have no interest in watching Friends. So I ignore it. The next time I login, it suggests Friends again and I ignore again. This goes on for quite a few number of logins until Netflix finds content that is probably more relevant to me than Friends. My question is this: Is there a way to use the information …
Category: Data Science

How to change URL structure for pagination pages?

Hi I'm new to WordPress hence if my question was simple or stupid I'm sorry, but please someone tell me how to change URL for pagination pages. Currently I'm having URL for pagination pages as: www.example.com/category_name.html/1 www.example.com/category_name.html/2 www.example.com/category_name.html/3 etc. But I need to change this URL structure as: www.example.com/category_name.html?page=1 www.example.com/category_name.html?page=2 www.example.com/category_name.html?page=3 etc. I tried something like this but it's not working. add_action( 'init', 'add_author_rules' ); function add_author_rules() { add_rewrite_rule( "bycategory/108-abodes-of-vishnu)/?$", "category_name=$matches[1]&paged=$matches[2]", "top"); } Any help would be greatly appreciated.
Category: Web

How can all E-mails be sent with BCC copy to Admin?

I'm translating WordPress page into seven different languages. Have around 70 plugins active and working, no worries. Subscriptions, shop, pre-orders you name it. Getting there with translations, using WPML but I have not found, not even searching, all templates for emails going out to users, customers, shop editors, bloggers, etc. I'm sending all emails out through Mailster. Is there a way that would be Admin able to get BCC copy of each and every e-mail sending out? I would take …
Category: Web

What is an arbitrary URL?

I have created a plugin for wordpress but I don't understand what an "arbitrary URL" is. Here's what I've found: When installed, the plugin has to make a custom endpoint available on the site of WordPress. By "custom endpoint" we refer to an arbitrary URL not recognized by WP as a Standard URL, like a permalink or so. Please note that this is not a point of REST connection. When a visitor navigates to that endpoint, the plugin has to …
Category: Web

Keras very low accuracy, saturate after few epochs while training

I am very new to the data science domain and directly jumped to TensorFlow models. I've worked on examples provided on the website before. My first time doing any project using it. I am building a Cricket Score Predictor using Keras, Tensorflow. I have a dataset of details of players in a csv containing columns - "striker", "non_striker", "bowler", "run_per_ball", "run_per_ball_avg", "ball_count". "ball_count" and "run_per_ball" are labels of the model and rest are features. I have a total of 51555rows …
Category: Data Science

enqueuing external and internal js and css in wordpress did not work with owl.js animate.css

<?php function cadentic_files () { wp_enqueue_script('cadentic_owl_carousel',get_theme_file_uri('js/owl.carousel.min.js'), array('jquery'), time(), true ); wp_enqueue_script('cadentic_wow_carousel',get_theme_file_uri('js/wow.min.js'), array('jquery'), time(), true ); wp_enqueue_script('cadentic_jquery_carousel',get_theme_file_uri('js/jquery-multitabs.js'), array('jquery'), time(), true ); wp_enqueue_script('cadentic_jquery1113_carousel',get_theme_file_uri('js/jquery-1.11.3.min.js'), array('jquery'), time(), true ); //wp_enqueue_script('cadentic_bootstrap_carousel',get_theme_file_uri('js/bootstrap.min.js'), array('jquery'), time(), true ); wp_enqueue_style('cadentic_font_awesome','https://fonts.googleapis.com/css?family=Roboto:300,400,500,600,700,900', false); wp_enqueue_style('cadentic_font_popins','https://fonts.googleapis.com/css?family=Poppins:100,200,400,300,500,600,700', false); wp_enqueue_style('cadentic_font_confortaa','https://fonts.googleapis.com/css?family=Comfortaa:300,400,700|Josefin+Sans:100i,300,400,700|Raleway:100,200,300,400,500,600,700,800,900', false); wp_enqueue_style('cadentic_main_styles',get_stylesheet_uri(), false); wp_enqueue_style('cadentic_animate_styles',get_theme_file_uri('css/animate.css'), false); wp_enqueue_style('cadentic_owl_styles',get_theme_file_uri('css/owl.theme.default.min.css'), false); //wp_enqueue_style('cadentic_owlcarousel_styles',get_theme_file_uri('css/owl.carousel.min.css'), false); wp_enqueue_style('cadentic_bootstrap_theme_styles',get_theme_file_uri('css/bootstrap-theme.min.css'), false); wp_enqueue_style('cadentic_jquery_styles',get_theme_file_uri('css/jquery-multitabs.css'), false); wp_enqueue_style('cadentic_font_awesome_styles',get_theme_file_uri('css/font-awesome.min.css'), false); wp_enqueue_style('cadentic_main_css_styles',get_theme_file_uri('css/main.css'), false); wp_enqueue_style('cadentic_responsive_css_styles',get_theme_file_uri('responsive.css'), false); wp_enqueue_style( 'bootstrap', '//stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css', false); wp_enqueue_script( 'owl-js', 'https://cdnjs.cloudflare.com/ajax/libs/owl-carousel/1.3.3/owl.carousel.min.js',array('jquery'), time(), true ); wp_enqueue_script( 'jq-js', 'https://code.jquery.com/jquery-3.5.0.js', array('jquery'), time(), true ); wp_enqueue_style( 'wpdocs-datatables-bootstrap-style', 'https://cdnjs.cloudflare.com/ajax/libs/datatables/1.10.21/css/dataTables.bootstrap4.min.css' ); wp_enqueue_style( 'wpdocs-bootstrap-style', 'https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.5.2/css/bootstrap.min.css' ); // …
Category: Web

How to get meta data from custom category name

I want to get meta data by custom post type category name. Right now i am getting all meta data but i want specific for each category $partSql = $wpdb->get_results("SELECT * FROM ".$wpdb->prefix."postmeta WHERE meta_key = 'prd_part_no'", ARRAY_A);
Category: Web

Keras+Tensorflow does not learn label for blank image

I have a Keras model and I want to do some cool visiualizations with it. It's an object recognition network. So I thought, It would be cool to input a blank image into the network and treat the image as the variable and not the weights, and then train the network to always output an icecream for example. So I wrote the following code: #loading the model model = load_model('model.h5') #create the input image as a variable w = tf.Variable(tf.zeros([1,224,224,3])) …
Category: Data Science

Model prediction on meshgrid in python

Suppose I have data with two independent variable $X_1$, $X_2$ and one dependent variable say $y$, as follows: $X_1$: $x_{1,1}$, $x_{1,2}$ , $x_{1,3}$ $X_2$: $x_{2,1}$, $x_{2,2}$, $x_{2,3}$ $y$: $y_1$, $y_2$, $y_3$ I built some Machine learning model which is good . Now I want to generate predictions not just for test data but for all possible combinations of test data for example, if our test data looks like $X_1$: $a$, $b$, $c$ $X_2$: $p$, $q$, $r$ then I want predictions …
Category: Data Science

Customize a WP_Posts_List_Table class

How can I customize output of tables of records in wp-admin/edit.php? What options are available for editing display_tablenav('top') and display_tablenav('bottom') before outputting in class WP_Posts_List_Table? I would like to insert my block between the table where records are displayed and the filters, for example: <h3>Titlle</h3>. No matter what. The Codex is written: This class's access is marked as private. That means it is not intended for use by plugin and theme developers, but only by other core functions and classes. …
Category: Web

How do I use TF*IDF scores for my machine learning model?

I have applied TF*IDF on the 'Ad-topic line' column of my dataset. For every ad-topic line, I get the same output: Firstly, I am unable to make sense of the output. The TF*IDF values are mentioned to the right, but what exactly are the numbers in brackets? I plan to use these for my logistic regression model for classification. How exactly do I feed these values to the algorithm?
Category: Data Science

get_posts only getting most recent product

I had a website built on Woocommerce for me, but no longer have access to the Developer. I'm not a programmer so anything beyond CSS changes gives me quite a bit of problems. There is a piece of code that was working fine, but I have added an additional item to the site and now it only will fetch the most recent item added. I believe the problem is that get_posts is only collecting the latest product and I need …
Category: Web

Spark ALS-WR giving the same recommended items for all users

We are trying to build a recommendation system for a supermarket with diverse item types (ranging from fast-moving grocery to low-moving electronic items). Some items are purchased more frequently in high volume and some items are purchased only once. We have purchase history data of 4 months from 25K+ customers across 30K+ SKU's from 100+ departments. We ran ALS-WR in Spark to generate recommendations. To our surprise, we are receiving top 15 recommendations for each customer quite generic without much …
Category: Data Science

WordPress import not importing custom taxonomy

I've posted this already in the WP Support Forum hoping to have more luck here. I'm trying to import a custom post type from one blog to another. (126 posts in the custom post type). I've exported using WordPress' export function from WP version 3.3.2 and trying to import into 3.2.1. I can get all the posts to import into the correct custom post type, but none of my custom taxonomy or meta information is being imported in. In both …
Category: Web

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.